On Mon, 2009-08-31 at 01:18 -0400, Uri Guttman wrote: > >>>>> "TB" == Tim Bowden <tim.bow...@mapforge.com.au> writes: > > TB> On Sun, 2009-08-30 at 21:53 -0700, John W. Krahn wrote: > >> Tim Bowden wrote: > >> > I'm trying to extend (again) the short regex checking script given in > >> > Learning Perl (Absolutely fabulous book btw! Highly recommend it to > >> > anyone trying to learn Perl). I'd like to cycle through the memory > >> > variables printing those as well as $`, $& and $' as given in the > >> > original script. Are these ($1, $2...) stored in some array also? > >> > >> Not directly, but you can use the @- and @+ arrays and substr() to > >> access what are captured by parentheses in a regular expression. > >> > >> perldoc perlvar > > TB> Thanks John, that looks like just the thing. > > do you know you can also get all the $1 values if you put the regex into > list context? you can assign them all to an array or a list of scalars, > etc.
Interesting. *scratch head* Makes sense. I'll have a play with it. Looks like a good idea. > > and you shouldn't use $& and friends as they can slow down all your > other s/// calls in your entire program. this has been covered many > times so you can search for why. > Yes, I was aware of that, but thanks for the reminder. In this case it's not a problem, because the script is purely for the purpose of testing any one given regex that I'm wanting to use elsewhere and so long as it doesn't take more than a few seconds to process I'm not worried. ;-) > uri > Thanks, Tim Bowden -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/