awohld has asked for the wisdom of the Perl Monks concerning the following question:
How is $1 getting its value?use strict; use LWP 5.64; my $browser = LWP::UserAgent->new; my $url = 'http://www.cpan.org/RECENT.html'; my $response = $broswer->get($url); die "Can't get $url -- ", $response->status_line unless $response->is_success; my $html = $response->content; while( $html =~m/<A HREF=\"(.*?)\"/g) { print "$1\n"; }
This some example code from the book "Spidering Hacks" and I'm not sure if it's a typo or something I'm missing.
Thanks
Adam
Update: Ahh I see, m//the expression is returning a list of matched values, with the first match it stores the (.*?) value at $1. Got it. Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How is this printing?
by Sandy (Curate) on Oct 15, 2004 at 20:32 UTC | |
by muba (Priest) on Oct 16, 2004 at 14:47 UTC | |
by Sandy (Curate) on Oct 19, 2004 at 17:04 UTC | |
by muba (Priest) on Oct 19, 2004 at 20:18 UTC | |
|
Re: How is this printing?
by Fletch (Bishop) on Oct 15, 2004 at 20:26 UTC | |
|
Re: How is this printing?
by SamCG (Hermit) on Oct 15, 2004 at 21:13 UTC | |
|
Re: How is this printing?
by ccn (Vicar) on Oct 15, 2004 at 20:27 UTC | |
|
Re: How is this printing?
by TedPride (Priest) on Oct 15, 2004 at 21:38 UTC |