Hi, I am trying to understand WWW::Mechanize
I understand that the downloaded content is stored in content(). Why am I not able to use a regex on it in scalar form? ------code------ use strict; use warnings; use WWW::Mechanize; my $mech = WWW::Mechanize->new(); $mech->get("http://checkip.dyndns.org"); my $last_page = $mech->content(); # last page fetched # this works if I store content in an array @last_page # for ( @last_page ) { # if ( m/([\d+.]+)/ ) { # print "$1\n"; # } # } # ( my $ip ) = grep/(\d+\.)/, $last_page; ( my $ip = $last_page ) =~ m/([\d+\.]+)/; print "$ip\n"; ------end------ my $ip gets the whole source page as its value. -- Got it while writing out this post :) -- Now the question becomes what is the difference between these two? ( my $ip = $last_page ) =~ m/([\d+\.]+)/; ( my $ip ) = ( $last_page ) =~ m/([\d+\.]+)/; I think the above one is "wrong syntax" for using list context? Also how can I make grep work? ( my $ip ) = grep/(\d+\.)/, $last_page;