On Sun, Jan 18, 2015 at 9:28 AM, Jim Gibson <jimsgib...@gmail.com> wrote: > >> On Jan 18, 2015, at 9:03 AM, Mike <ekimduna...@gmail.com> wrote: >> >> I was able to find match extraction in the perldoc. >> >> Here is a snippet of what I have. >> >> my $insult = ( $mech->text =~ m/Insulter\ (.*)\ Taken/ ); >> print "$insult\n"; >> >> But $insult is being populated with: 1 >> >> It should be populated with text. Can anyone tell me what I'm doing wrong >> here? > > Your error is assigning the return value of the regular expression in a > scalar context. In scalar context, a regular expression returns true or false > indicating a match (or not). In array context, however, it returns the > captured subexpressions as a list. > > Try forcing the assignment into array context: > > my( $insult ) = ( $mech->text =~ m/Insulter\ (.*)\ Taken/ ); > ...
For more info: see perldoc perldata. There a full discussion of list vs scalar context . -- Charles DeRykus -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/