APM: RegEx question

Wayne Walker wwalker at broadq.com
Thu Jan 9 19:56:11 CST 2003


I can't find the reference to back it up, but $1, $2, ... are locally
scoped.  That is, they disappear when you leave the block ({ ... }) they were
created (by the regex call) in.

On Thu, Jan 09, 2003 at 07:05:07PM -0600, Goldilox wrote:
> What's the difference? Latter version doesn't work. Do RegEx's associate (or
> whatever the word is when $& becomes defined) at compile time or run time?
> 
> unless($timeinfo=~/@/g){$timeinfo=~m!^(\w+)\s(\d\d),\s(\d{4})$!;$month=$1;$day=$2;$year=$3;}
> else{$timeinfo=~m!^(\w+)\s(\d\d),\s(\d{4})\s\@\s(\d\d):(\d\d)\s(\w\w)$!;$month=$1;$day=$2;$year=$3;}
> }
> 
> vs
> 
> unless($timeinfo=~/@/g){$timeinfo=~m!^(\w+)\s(\d\d),\s(\d{4})$!;}
> else{$timeinfo=~m!^(\w+)\s(\d\d),\s(\d{4})\s\@\s\d\d:\d\d\s\w\w$!;}
> $month=$1;
> $day=$2;
> $year=$3;
> }
> 
> Rhett
> 
> _______________________________________________
> Austin mailing list
> Austin at mail.pm.org
> http://mail.pm.org/mailman/listinfo/austin

-- 

Wayne Walker

www.broadq.com :)  Bringing digital video and audio to the living room

And the "Wizard of Bill" says "Please ignore the crash behind the Windows."



More information about the Austin mailing list