Kage has asked for the wisdom of the Perl Monks concerning the following question:
Okay, I need to parse through every file I have on my server that has the extention of .shtml and find all instances of <a href="main.php?page=...."> and change the main.php?page= to /?id= ONLY of the main.php?page is in an anchor href.
I have it down to a point of near complete, but apperantly, substitute, transition, and all those only want to switch once.
Any ideas on how to do this?
“A script is what you give the actors. A program is what you give the audience.” ~ Larry Wall
I have it down to a point of near complete, but apperantly, substitute, transition, and all those only want to switch once.
sub changelinks { my ($file) = @_; if (-d $file) { opendir(DIR, $file) || die "$!"; my @filenames = readdir(DIR); foreach my $filename (@filenames) { if (($filename ne "." && $filename ne "..")) { changelinks($file."/".$filename); } } closedir(DIR); } else { if ($file =~ /.shtml/i) { And then whatever method of opening and editing each file goes here } } }
Any ideas on how to do this?
“A script is what you give the actors. A program is what you give the audience.” ~ Larry Wall
Back to
Seekers of Perl Wisdom