in reply to Scraping Ebay

In the future please only post the relevant code. Trim your examples down to the minimal case that still demonstrates the problem. See How (not) to ask a question - Only Post Relevant Code

Here is a somewhat trimmed down version:

use warnings; use LWP 5.64; use URI; use HTML::LinkExtor; my $base = "http://search.ebay.com/ws/search/SaleSearch"; my $browser = LWP::UserAgent->new; my $url = URI->new($base); $url->query_form( 'satitle'=> 'learning perl', 'sacat'=> 267, ); my %data = (); # set up the link handler sub my $link_extor = HTML::LinkExtor->new(\&handle_links); #get search results my $response = $browser->get($url); #get the links $link_extor->parse($response->content); exit; ###################################### sub handle_links { my ($tag, %links)=@_; if ($tag eq 'a') { foreach my $key (keys %links) { #search for links with Viewitem if ($key eq 'href') { if ( $links{$key} =~ m/ViewItem/) { #get the item number from the link $links{$key} =~ m/item=(\d+)/; printf "links{%s} = %s\n",$key,defined $links{$key +} ? $links{$key} : 'undef'; if (!defined $1) { die "\$1 is undefined."; } $data{$1}=$links{$key}; } } } } }
Output:
links{href} = http://cgi.ebay.com/Learning-Perl-by-Randal-L-Schwartz-1 +997_W0QQitemZ220021417901QQihZ012QQcategoryZ2228QQssPageNameZWDVWQQrd +Z1QQcmdZViewItem $1 is undefined. at test.pl line 43.
The warning is being printed because while $links{$key} =~ m/ViewItem/ matches, $links{$key} =~ m/item=(\d+)/ does not.

To avoid warnings like this you should always check that the regex was succesful before checking $1.