- publishing free software manuals
Perl Language Reference Manual
by Larry Wall and others
Paperback (6"x9"), 724 pages
ISBN 9781906966027
RRP £29.95 ($39.95)

Sales of this book support The Perl Foundation! Get a printed copy>>>

Missing right brace on \\N{} or unescaped left brace after \\N

(F) \N has two meanings.

The traditional one has it followed by a name enclosed in braces, meaning the character (or sequence of characters) given by that name. Thus \N{ASTERISK} is another way of writing *, valid in both double-quoted strings and regular expression patterns. In patterns, it doesn't have the meaning an unescaped * does.

Starting in Perl 5.12.0, \N also can have an additional meaning (only) in patterns, namely to match a non-newline character. (This is short for [^\n], and like . but is not affected by the /s regex modifier.)

This can lead to some ambiguities. When \N is not followed immediately by a left brace, Perl assumes the [^\n] meaning. Also, if the braces form a valid quantifier such as \N{3} or \N{5,}, Perl assumes that this means to match the given quantity of non-newlines (in these examples, 3; and 5 or more, respectively). In all other case, where there is a \N{ and a matching }, Perl assumes that a character name is desired.

However, if there is no matching }, Perl doesn't know if it was mistakenly omitted, or if [^\n]{ was desired, and raises this error. If you meant the former, add the right brace; if you meant the latter, escape the brace with a backslash, like so: \N\{

ISBN 9781906966027Perl Language Reference ManualSee the print edition