>>>>> "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.

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.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to