Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Super Find critic needed

by Skeeve (Vicar)
on Jun 30, 2003 at 12:41 UTC ( #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 "..." } } } }


Comment on Re: Super Find critic needed
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (9)
As of 2014-12-21 20:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (107 votes), past polls