Re: Basic Perl text substitution
Originally Posted by
hailholyghost
Hello,
I would like to combine these two Perl substitutions
Code:
my $name = $file;
$name =~ s/.out$//;
$name =~ s/^nmr//;
into a single command, just like sed can do:
Code:
sed -e 's/^nmr//g' -e 's/out$//g'
I know that Perl was meant to mimic the way that sed works, but it doesn't work *exactly* the same.
The program I have now works, but I would like to make it better.
Thanks very much!
Why? Doing so makes your code harder to understand. Avoid micro-optimization; it never improves the code.
Just my 0.00000002 million dollars worth,
Shawn
Programming is as much about organization and communication as it is about coding.
Bookmarks