I checked the locale:

LC_COLLATE = C

Thanks,

-Nilanjan


-----Original Message-----
From: Steven W. Orr [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 02, 2004 3:32 PM
To: Palit, Nilanjan
Cc: boston perl mongers; [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: [Boston.pm] Weird regex behavior?

On Monday, Aug 2nd 2004 at 05:04 -0700, quoth Palit, Nilanjan:

=>Folks,
=>
=>Here's a weird regex behavior I'm getting that I don't understand.
=>
=>Problem description: Look at the 2 "if (s/.../.../)" statements below 
=>[marked (Case A) & (Case B)]. They are basically identical & each get 
=>the same input. The only difference is that the 2nd regex has a "\s*"
at 
=>the start of the pattern that the first one doesn't.
=>
=>In each case, the actual $_ substitution occurs fine. Case A seems to 
=>behave as expected. However, in case B, somehow $1 & $2 lose their
value 
=>once inside the {}.
=>
=>What gives?

I'm wondering if it's not a version problem but a locale problem. What
are 
you LOCALE and other associated variables set to (e.g., LC_COLLATE, 
etc...)

=>
=>Code and output is provided below.
=>
=>
=>Code:
=>----
=>
=>#!/usr/local/bin/perl
=>
=>print "(Case A)\n";
=>@strings= ("fooxyzbar 123", "fooabcde 123");
=>foreach (@strings)
=>{
=>   if (s/(foo)(.+)\s+\d+/$2/g)
=>   {
=>      print "'$_' -> :$1:$2:\n";
=>   }
=>}
=>
=>print "\n\n";
=>
=>print "(Case B)\n";
=>@strings= ("fooxyzbar 123", "fooabcde 123");
=>foreach (@strings)
=>{
=>   if (s/\s*(foo)(.+)\s+\d+/$2/g)
=>   {
=>      print "'$_' -> :$1:$2:\n";
=>   }
=>}
=>
=>
=>Output:
=>------
=>
=>(Case A)
=>'xyzbar' -> :foo:xyzbar:
=>'abcde' -> :foo:abcde:
=>
=>
=>(Case B)
=>'xyzbar' -> :::
=>'abcde' -> :::
=>
=>
=>
=>
=>Thanks,
=>
=>-Nilanjan
=>
=>
=>
=>
=>_______________________________________________
=>Boston-pm mailing list
=>[EMAIL PROTECTED]
=>http://mail.pm.org/mailman/listinfo/boston-pm
=>

-- 
Time flies like the wind. Fruit flies like a banana. Stranger things
have  .0.
happened but none stranger than this. Does your driver's license say
Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are
all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net

_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to