Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
×
User Journal

Journal JazzHarper's Journal: A Perl Lesson for the Day 1

If you have a block of quoted text inside the single-quoting operator q(), a backslash preceding a '(' or ')' (or whatever delimiter characters you have chosen for q()), will be parsed as an escape on that delimiter character. Therefore, you must escape any literal backslash if it appears before '(' or ')'.

Example:

#!/usr/bin/perl -w
print q(
This is a test... x(1), x\(2\), x\[3\], x\\(4\\).
);

The rationale for this undocumented Perl feature is reasonable. The q() operator will ignore balanced pairs of delimiter characters that appear in the enclosed text, but it is sometimes necessary to write text that contains unbalanced delimiters. To make that possible, the q() operator must recognize the escape on its delimiters.

This discussion has been archived. No new comments can be posted.

A Perl Lesson for the Day

Comments Filter:
  • Why the fuck would anyone play a diatonic harp? What is wrong with you? If you want to play an obsolete, unused sort of harp, try looking up one of the old double-row Chromatic Harps. No pedals, fully chromatic. They are even a step up from the standard diatonic-but-chromatic-through-pedals harp.

Top Ten Things Overheard At The ANSI C Draft Committee Meetings: (5) All right, who's the wiseguy who stuck this trigraph stuff in here?

Working...