Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: can i get a matched values as an array

by gone2015 (Deacon)
on Feb 17, 2009 at 14:50 UTC ( [id://744426] : note . print w/replies, xml ) Need Help??


in reply to can i get a matched values as an array

BTW, your:

$str =~ s/age ([0-9]+) name ([a-z]+)/$&/ ;
is matching something and then replacing it by itself. Not only does this seem a little pointless (why not just  m/age ([0-9]+) name ([a-z]+)/ ?), but the documentation warns that:
The use of this variable anywhere in a program imposes a considerable performance penalty on all regular expression matches.
so using $& when you don't absolutely need it looks like a mistake...