in reply to print the whole line

/abc/ and print for @mydata;

If you want to print the whole line whenyou get a hit, your /g modifier serves no purpose.

$_ =~ /abc/ is doing the same as /abc/. If your going to use $_, you might as well make full use of it:)


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
Timing (and a little luck) are everything!

Replies are listed 'Best First'.
Re: Re: print the whole line
by Anonymous Monk on Jan 21, 2004 at 14:14 UTC
    Thanks but for some reason it prints out the whole page when I get a hit and not just each line that I get a hit on.
    my $content = get($url); /abc/ and print for $content;

      That's because you have the whole page stored as a single line. In your original post you showed an array. Try

      my @content = split /\n/, get($url); /abc/ and print for @content;

      But note: What will be considered a "line" in html source bears no realationship to the "lines" that appear on the screen in your browser.


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "Think for yourself!" - Abigail
      Timing (and a little luck) are everything!

        Thanks!!! This was a great learning experience.
      No need to split $content up into separate lines first. Try something like:
      my $content = get($url); print $content =~ /^(.*abc.*\n)/m;
      (If you don't need $content for anything else, you can just put the get($url) in its place on the print line.)