in reply to Re: =~ and substitutions
in thread =~ and substitutions

Let's say I am searching for the word "test", when the results are brought back it brings back the entire line of code with "test" inside rather than just the single word I was looking for. And my substition isn't removing the code tags when all I want is the text.

"Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

sulfericacid

Replies are listed 'Best First'.
Re^3: =~ and substitutions
by tall_man (Parson) on Mar 03, 2003 at 20:26 UTC
    Ok, here's a sample program with some input data and resulting output. Is this what you mean?
    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
    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.
    test test hello meta fadfdsa <p> meta test test test test meta