in reply to Re^2: Page Scraping
in thread Page Scraping

You could work this out yourself, but

$artist_link->url() =~ /(\d{9})/; print $pro_list $1, "\n";

should help.

Ask if you don't understand some parts of my script.

Replies are listed 'Best First'.
Re^4: Page Scraping
by shigetsu (Hermit) on May 01, 2007 at 21:36 UTC

    That doesn't catch cases when the regular expression doesn't match and hence $1 might have a value assigned to it from a previous successful capturing regular expression match.

    I humbly suggest either:

    print {$pro_list} $1, "\n" if $artist_link->url() =~ /(\d{9})/;
    or
    if ($artist_link->url() =~ /(\d{9})/) { print {$pro_list} $1, "\n"; }

    The curly braces around {$pro_list} disambiguates its use as the filehandle that is printed to.

      We selected all links whose URL matches the regexp, then we loop through tnem. I'd say it always matches.