On Wed, Apr 2, 2008 at 3:09 PM, Peter Abbott <[EMAIL PROTECTED]> wrote:
> 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.
I suspect that the added line resets the back-references (the
"$1".."$6"). Try moving it under the $margin assignment (i.e. until
after you are done with the back-references).
--Amos
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html