Gossamer Forum
Home : General : Perl Programming :

altavista.cgi

Quote Reply
altavista.cgi
Could anybody explain to me (step/by/step) what functions this part does:

Code:
while ($results =~ m#<dl><dt><b>(\d+)\.\s*</b><a href="([^"]+)"><b>([^<]+)</b></a><dd>([^<]*)<?b?r?>?<b>URL:</b> <font color=gray>([^<]+)<br>([^<]+)</font>#sog) {
($count, $url, $title, $description, $url2, $last) = ($1, $2, $3, $4, $5, $6);
$output .= qq~<p>$count - <a href="$url">$title</a> : $last<br>$description~;
}

Thank you.
Quote Reply
Re: altavista.cgi In reply to
umm.. ok

it checks to see if the page result has that in it..

\d+ means one or more digits..
\. means ".".. period..
\s* means zero or more spaces
[^"]+ means anything but ".. (one or more times)
[^<]+ means anything but <.. (one or more times)
[^<]* means anything but <.. (zero or more times)

the () around any of it means to localize those as variables..

which you see on the next line.. $1, $2, $3, $4, $5, $6 are the variables that were received between those () in the order they appear..

it's just simple pattern matching..

jerry
Quote Reply
Re: altavista.cgi In reply to
<?b?r?>?

pretty much means if there is a <br> there or not..

j? would see if j is there.. etc

Quote Reply
Re: altavista.cgi In reply to
Thank you.