in reply to (tye)Re: Elegant way to parse an optional prefix with default?
in thread Elegant way to parse an optional prefix with default?

Yow! I didn't know it did that in character classes.

Interesting... this relies on undef being dropped in list catenation, so '&' becomes the first element?

  • Comment on Re: (tye)Re: Elegant way to parse an optional prefix with default?

Replies are listed 'Best First'.
(tye)Re2: Elegant way to parse an optional prefix with default?
by tye (Sage) on Nov 08, 2002 at 17:31 UTC

    Whether to treat $ and @ as literals or not inside a regular expression is the single most complicated case of DWIM in Perl. It calculates weights to make this decision. I hate that it results in /[$]/ being a syntax error.

    And it is good that character classes are not exempted as $anagram !~ /[^\Q$word\E]/ is actually useful code.

    Yes, if you turn on warnings you'll get "Use of uninitialized value in pattern match (m//)".

            - tye