[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] How to match \* (MacPerl bug or my mistake)?



In message <34198ED3.40E3@remove.thiis.freytag.org> you write:
>I have been digging through the O'Reilly book 
>_Learning_Perl_.  Ran into a problem and I can't 
>believe that MacPerl isn't doing it right.  

Depends on how you define "right" :-)

>The goal is to match 0 or more / marks.  I can't
>do it and I -think- I'm coding correctly.  
>
>Here is the test script, run it and it explains the 
>problems I'm seeing:

>$a =~ m#(\\*\**)#;

& so on & so forth.

The subtlety that Paul was missing (and that, indeed, probably anyone not 
reading Perl5-Porters would miss) is that these examples use # as a regexp
separator. The status of # for this purpose has changed in pretty much every
perl5 sub-release since 5.000, and since MacPerl 5.1.3 is based on 5.002, it
behaves a bit differently than MacPerl 5.1.4b or your typical Unix-Perl.

If and how # is legit as a regexp separator might not even be clear at the
moment. To understand why # is problematic, consider the following (courtesy
of Tom Christiansen):

s{Some Regexp}  # The case of some regexp
  {Replacement};

So the morale: Until the status of # has settled, don't use it in regexps 
(I personally like s|x|y|).

Matthias

-----
Matthias Neeracher   <neeri@iis.ee.ethz.ch>   http://www.iis.ee.ethz.ch/~neeri
   "I'm set free to find a new illusion" -- Velvet Underground


***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch