- To: slug@xxxxxxxxxxx
- Subject: [SLUG] Perl Question
- From: Peter Abbott <abbottp_c@xxxxxxxxxxxxxxxx>
- Date: Wed, 02 Apr 2008 15:09:44 +1100
Can anyone with greater knowledge than myself explain this regex
behaviour.
This code segment works as intended:
if ( $_ =~ m/^Box(\d) ([A-Z]+(\. | ?)[A-Z]* ?[A-Z]*).*?(\d).*?(\d\d\.\d
\d).*?(\d*\.\d\d)L/) {
$box = $1;
$name = $2;
$place = $4;
$time = $5;
$margin = $6;
$name =~ s/\.//;
}
However if the $name substitution is inserted above $place like so it
fails to allocate values to $place, $time and $margin.
if ( $_ =~ m/^Box(\d) ([A-Z]+(\. | ?)[A-Z]* ?[A-Z]*).*?(\d).*?(\d\d\.\d
\d).*?(\d*\.\d\d)L/) {
$box = $1;
$name = $2;
$name =~ s/\.//;
$place = $4;
$time = $5;
$margin = $6;
}
Undoubtedly something simple that a self taught dummy has failed to
grasp.
Regards,
Peter.
Happy & proud to be,
100% Microsoft free.