Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Super Find critic needed

by Skeeve (Parson)
on Jun 30, 2003 at 12:41 UTC ( [id://270145]=note: print w/replies, xml ) Need Help??


in reply to Super Find critic needed

This comes to my mind:
  1. Why don't you do the replacements in NameReplace instead of pushing all filenames to a global array?
  2. I'd use
    s/\bservername(?:\.aa\.company(?:\.zzzz)?\.com)?\b/NEWNAME.\com/gi;
    in favour of your 3 replacements.
I don't know whether or not this will be more efficient (untested, incomplete code):
sub NameReplace { if( $_ =~ /\.(?:html?|cfm|cfml|cgi|js|pl)$/) { my $name = $File::Find::name; open ( F, $name ) || warn "$!: $name\n"; $data=join '',<F>; close (F); if ($data=~ s/\bservername(?:\.aa\.company(?:\.zzzz)?\.com)? +\b/NEWNAME.\com/gi) { if (open (F, ">$name")) { print F,$data; close(F); } else { warn "..." } } } }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (1)
As of 2024-04-24 14:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found