in reply to Re: Re: =~ and substitutions
in thread =~ and substitutions
Every line containing "test" will cause a line with the word "test" in the output. Lines containing "test" and "meta" will have paragraph code tags stripped. Lines containing "meta" alone will be printed unchanged. Other lines will be skipped.use strict; my @lines = <DATA>; my $line; foreach $line (@lines) { if($line =~ /(test)/) { print $1,"\n"; $line =~ s/<p>//gi; } if($line =~ /meta/) { print "$line" }; } __END__ test <p> hello meta fadfdsa <p> meta fadfasd test test <P> test meta <p> fdafasdg
test test hello meta fadfdsa <p> meta test test test test meta
|
|---|