angie ahl wrote: > hi people > > I'm trying to get the value of $1 into a var, the following don't work > and I can't figure out why > > $_ = $html_body; > my ($resrow) = m#<!-- VM: resrow -->(.*?)<!-- VM: /resrow -->#; > #print $1; > print $resrow; > > $resrow holds nothing, however if I print $1 I do have a match
How do you know? How are you testing to ensure that a match was found? > > > $_ = $html_body; > m#<!-- VM: resrow -->(.*?)<!-- VM: /resrow -->#; > my $resrow = $1; > print $resrow; > > doesn't work either. > > How do I get $1 into a var for later use. It's driving me a little loopy > now. Just the way you show in your second example. If a match was found, the captured text will appear in $resrow. Better to find out: if (m#<!-- VM: resrow -->(.*?)<!-- VM: /resrow -->#) { print "$1\n"; } else { print "Oops, back to the drawing board with this regex, huh?\n"; } Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>