Package: perl
Version: 5.8.7-4
Tags: upstream

When square or round brackets are used as regular expression delimiters,
the expression apparently cannot contain a backslash-escaped literal
opening delimiter bracket.

I see nothing in the documentation to suggest that this is intentional
or expected behavior.

 vnix$ $ perl -ne 'print if m(\()' </dev/null
 Unmatched ( in regex; marked by <-- HERE in m/( <-- HERE / at -e line
 1.

 vnix$ perl -ne 'print if m[\[]' </dev/null
 Unmatched [ in regex; marked by <-- HERE in m/[ <-- HERE / at -e line
 1.

Note that in the error message, the backslash is missing.

The closing square bracket works as expected:

 vnix$ perl -ne 'print if m[\]]' </dev/null

But with the rounded parens, the closing paren too is mishandled:

 vnix$ perl -ne 'print if m(\))' </dev/null
 Unmatched ) in regex; marked by <-- HERE in m/) <-- HERE / at -e line
 1.

With square brackets, you get an error message even if there is an
escaped pair:

 vnix$ perl -ne 'print if m[\[\]]' </dev/null
 Unmatched [ in regex; marked by <-- HERE in m/[ <-- HERE ]/ at -e line
 1.

If you remove the escape from the closing square bracket, you still get
the error:

 vnix$ perl -ne 'print if m[\[]]' </dev/null
 Unmatched [ in regex; marked by <-- HERE in m/[ <-- HERE / at -e line
 1.

Also note that the error message lacks the closing square bracket.

With rounded brackets, matching pairs work as expected:

 vnix$ echo 'foo()' | perl -ne 'print if m(\(\))' 
 foo()

Curly brackets and brokets work fine:

 vnix$ perl -ne 'print if m{\{}' </dev/null

 vnix$ perl -ne 'print if m<\<>' </dev/null

I'm afraid I don't have the means to test this with other versions of
Perl at the moment.


/* era */

-- 
If this were a real .signature, it would suck less.  Well, maybe not.



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to