APM: RegEx question

Goldilox Goldilox at teachnet.edb.utexas.edu
Thu Jan 9 19:05:07 CST 2003


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




More information about the Austin mailing list