- To: Slug <slug@xxxxxxxxxxx>
- Subject: Re: [SLUG] Perl Question
- From: "Amos Shapira" <amos.shapira@xxxxxxxxx>
- Date: Wed, 2 Apr 2008 15:38:06 +1100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=wlC4RMTJ60rN3+YeCBXtrPl86WyJzkG4bDT4tK0ayUA=; b=Wb7F6RBjiMUcDzmjJuTvGlRyeaHC/m5dsKOb9hrEb8SOozDlc9G1+Balu0zPvZam0WbCAu0B9h0o/grSC+/2lV4O8yEH54WemFH2yEGyu7UwlY00FJdCf0ey07ffzMrhecyv7wOXJA5/xRylhsuVZMhjtEIAyn0/HHBiV9BMNv8=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Xe6cDUPcjmUnuhsigCjUOus4nKekLexHXUlZl36KaJPOtUTOSQPVRPBXWRxINcQ9gwBw8LdsZnRumeD4Pf3Tr+gKUgCUYmY9mJ7E24hp8sww7C07b73p0AlqUDr3tH5vJIvVrYI2Aw25sAeQ5seEykr1go9lj0bwjDtHK4NtKwA=
On Wed, Apr 2, 2008 at 3:09 PM, Peter Abbott <abbottp_c@xxxxxxxxxxxxxxxx> 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