http://qs321.pair.com?node_id=969753


in reply to Substitution or removing characters from a file

Sure, just remove the newline:
$basename =~ s/\S*RDL/RDL/; $basename =~ s/.ruv$//;
Or
s/\S*RDL/RDL/, s/.ruv$// for $basename;
Or
$basename =~ s/\S*RDL((?s:.*)).ruv$/RDL$1/;
but why would you? The two lines are easy to understand, and certainly more efficient that the latter single substitution.

Replies are listed 'Best First'.
Re^2: Substitution or removing characters from a file
by Anonymous Monk on May 17, 2012 at 22:58 UTC
    Hello, Thanks for the reply. Am late in acknowledging it, was on travel. Thanks for your above suggestions. You said that two lines are more efficient than the single substitution. How can I tell, which part of my code is more efficient than other. I thought that 1 line would be more efficient than 2 lines, hence I posted this question. You have any suggestion/reading link for reading on writing efficient code in perl? Thanks.
      It was me who posted above msg. Not sure, how I got logged out in the process before posting that msg.