Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Substitution or removing characters from a file

by JavaFan (Canon)
on May 10, 2012 at 06:37 UTC ( #969753=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://969753]
help
Chatterbox?
[vedagiri89]: install perl5.16 in the new server and try to run appache
[hippo]: Which version of CentOS?
[vedagiri89]: how to fix: Attempt to reload DynaLoader.pm aborted
[hippo]: Ah, presumably 7 then.
[vedagiri89]: CentOS Linux release 7.0.1406 (Core)
[hippo]: How did you install libapreq2?
[vedagiri89]: that one is done by system team from the tar i guess
[hippo]: Really? Not using the one from the CentOS repository? Perhaps that's the problem.
[vedagiri89]: i need when this issue will come usually
[hippo]: How about mod_perl? Was that installed from the CentOS packge or from source?

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2018-06-19 11:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (113 votes). Check out past polls.

    Notices?