in reply to Re: print the whole line
in thread print the whole line

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;

Replies are listed 'Best First'.
Re: Re: Re: print the whole line
by BrowserUk (Patriarch) on Jan 21, 2004 at 14:18 UTC

    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.
Re: Re: Re: print the whole line
by ysth (Canon) on Jan 21, 2004 at 16:10 UTC
    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.)