in reply to Re: Key/Value pair from GET
in thread Key/Value pair from GET

This is a better example of what I am trying to do (should have been more clear, sorry). I am trying to get values of variables from a link along with the name of the link (Geography below). This might be in the HTML:
<a href="thepage.jsp?siteId=1&sectionId=443&amp;"> <span class="small">Geography</span></a>,

So I want to get 443 and Geography, in the form: 443,Geography. I still get nothing printed out on my command prompt. Here is my modified code to fit this model better:
#!perl use LWP::Simple; use strict; use warnings; #get the values out easily! my %categories = (); my $page = get 'http://www.thepage.com/thepage.html'; while ($page=~m/sectionId\=(\w+?)".+?\"small\">(\w+?)\</sg){ $categories{$1}=$2; print "[$1] and [$2]"; } my @pairlist = keys(%categories); my $idkey = (); foreach $idkey (@pairlist) { print "$idkey,$categories{$idkey}\n"; }


Michael Jensen
michael at inshift.com
http://www.inshift.com

Replies are listed 'Best First'.
Re: better example of what I am trying to do
by Abigail-II (Bishop) on Jun 06, 2002 at 09:55 UTC
    It's not hard to see why your regex goes wrong in the example given. Your regex expects "sectionId=", followed by one or more word characters, followed by a double quote. However, the data has "sectionId=", followed by 443 (which are word characters), followed by an ampersand. An ampersand is of course not a double quote.

    Abigail