s...@missionstclare.com wrote:
I am changing entire files.
I maintain missionstclare.com. I can create the daily files from Perl
scripts (and I do). Example at
http://www.missionstclare.com/english/March/morning/01m.html
But, to create the stripped-down versions of the same files (example at
http://www.missionstclare.com/english/March/whole/morning/01m.html), I
have to remove a great amount of stuff from the original daily files.
Like Tim, I've been using while(<>); but, from this discussion, I
suspect that while(<>) is the problem.
I've never used Slurp.
Now I think I see what the problem is. You are doing something like this:
while ( my $text = <FH> ) {
$text =~ s/george/tim/;
}
Which substitutes 'tim' for 'george' each time the value in $text
changes, which is for each line in the file.
If you only want the first instance of 'george' changed in the whole
file then you could use the spacial ?? pattern match:
while ( my $text = <FH> ) {
$text =~ ?george? && $text =~ s/george/tim/;
}
John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction. -- Albert Einstein
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/