09-16-2006, 03:00 PM
|
|
|
Totally Borked
Industry Role:
Join Date: Feb 2005
Posts: 6,284
|
Quote:
|
Originally Posted by boldy
I'm in a good mood today so i wrote this little perl script for you :
uploaded it and call it test.pl
then run it from the command shell:
(make sure you're into the public_html dir)
perl test.pl
Code:
#!/usr/bin/perl
# by boldy / EarlmillerCash.com
# Now promote Earlmillercash.com goddamnnit :)
my $lSearch = "foobar";
my $lReplace = "whatever";
# this will search and replace the above words, and it will create
# filename.html.test files if it matches the action.
# if you think it workds set $lTest to "" instead of ".test"
#
# and it will overwrite the file.
# make sure you're in the right directory by cd ing itto it
# eg .
# cd /web/sites/yourdomain.com/public_html
# set $lTest to "" when you think this works
# to delete the *.test files run: find ./ -name *\.test -exec rm {} \;
my $lTest = ".test";
my @lFiles = split ("\n" , `find ./ -type f` );
foreach my $lFile (@lFiles) {
print "Opening file " . $lFile . "\n";
open (INFILE,"<" . $lFile);
my @lLines =<INFILE>;
close INFILE;
my $lWrite = 0;
foreach my $lLine (@lLines) {
if ($lLine =~ m/$lSearch/) {
$lWrite = 1; last;
}
}
if ($lWrite) {
open (OUTFILE , ">" . $lFile . $lTest );
foreach my $lLine (@lLines) {
$lLine =~ s/$lSearch/$lReplace/g;
print OUTFILE $lLine;
}
close OUTFILE;
print $lFile.$lTest . " created \n";
}
}
|

__________________
For coding work - hit me up on andy // borkedcoder // com
(consider figuring out the email as test #1)
All models are wrong, but some are useful. George E.P. Box. p202
|
|
|