Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Change utility; code optimization

by coolmichael (Deacon)
on Feb 10, 2001 at 11:18 UTC ( #57593=note: print w/ replies, xml ) Need Help??


in reply to Change utility; code optimization

I can't offer any explanations why it isn't working for \n\r but I can offer some suggestions:

undef $/; $filecontemts=<DEFILE>
will slurp all of the file into $filecontents, then you don't need to worry about using join.
print "Changing \"$File::Find::name\" file...\n" if ($happens=($file_c +ontents =~ s/$changefrom/$changeto/g));
should make the substitution and return the number of times it happened all at once. It will only print if $happens isn't zero. It's a little hard to read, but you get used to it quickly. Then you are only doing one regex on the data, rather than two. (vice versa for case insensitive matching.)

I don't know if if($code =~ m/yY/) would be faster than testing for equality, but it is easier to read (at least for me anyway. YMMV)


Comment on Re: Change utility; code optimization
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://57593]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (10)
As of 2014-07-31 16:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (249 votes), past polls