in reply to Choosing regex delimiters

Can you provide sample data? They work the same for me with a dummy string (after I change "as $1" in the second):
$_ = "adfjdk.kkk,8888888"; s/(.*?)\.(\w\w\w),/iif([month]>,$1.$2,0) as $2/; print "$_\n"; $_ = "adfjdk.kkk,8888888"; s|(.*?)\.(\w\w\w),|iif([month]>,$1.$2,0) as $2|; print "$_\n"; # prints: # iif([month]>,adfjdk.kkk,0) as kkk8888888 # iif([month]>,adfjdk.kkk,0) as kkk8888888

Update: Isn't the orginal question essentially, Why does s/// differ from s|||, all other things being equal? (And I doubt the claim.) But the other responses looked at quotes, which were identical in both expressions. Am I missing the point? OP, can you provide working examples that illustrate the problem?

Replies are listed 'Best First'.
Re^2: Choosing regex delimiters
by xyzzy (Pilgrim) on Feb 06, 2009 at 18:05 UTC
    [01-estimate].jan, [01-estimate].feb, [01-estimate].mar, [01-estimate].apr, (etc...)
    This is on Windows XP using ActivePerl EE 5.8.6. Using s/// makes no substitutions, using s||| works as expected. Is this something specific to the XP command line?

      No surprises, I get the wrong results with double-quotes and the correct results with single-quotes; and identical results in each case, whether delimiting with / or |.

      $ perl -p -e "s/(.*?)\.(\w\w\w),/iif([month]>,$1.$2,0) as $2/" z.txt iif([month]>,.,0) as iif([month]>,.,0) as iif([month]>,.,0) as $ perl -p -e "s|(.*?)\.(\w\w\w),|iif([month]>,$1.$2,0) as $2|" z.txt iif([month]>,.,0) as iif([month]>,.,0) as iif([month]>,.,0) as $ perl -p -e 's|(.*?)\.(\w\w\w),|iif([month]>,$1.$2,0) as $2|' z.txt iif([month]>,[01-estimate].jan,0) as jan iif([month]>,[01-estimate].feb,0) as feb iif([month]>,[01-estimate].mar,0) as mar $ perl -p -e 's/(.*?)\.(\w\w\w),/iif([month]>,$1.$2,0) as $2/' z.txt iif([month]>,[01-estimate].jan,0) as jan iif([month]>,[01-estimate].feb,0) as feb iif([month]>,[01-estimate].mar,0) as mar
        I think it's an XP issue because I don't even get a substitution with s///

      It should and does work fine in XP's cmd shell.

      >perl -p -e "s|(.*?)\.(\w\w\w),|iif([month]>,$1.$2,0) as $2|" temp.txt iif([month]>,[01-estimate].jan,0) as jan iif([month]>,[01-estimate].feb,0) as feb iif([month]>,[01-estimate].mar,0) as mar iif([month]>,[01-estimate].apr,0) as apr >perl -p -e "s/(.*?)\.(\w\w\w),/iif([month]>,$1.$2,0) as $2/" temp.txt iif([month]>,[01-estimate].jan,0) as jan iif([month]>,[01-estimate].feb,0) as feb iif([month]>,[01-estimate].mar,0) as mar iif([month]>,[01-estimate].apr,0) as apr

      Tested with with ActivePerl 5.6.0, 5.6.1, 5.8.0, 5.8.8, 5.10.0