in reply to Re: How does the built-in function length work?
in thread How does the built-in function length work?

I tried :

print length("\N{LATIN CAPITAL LETTER E WITH ACUTE}ric");

and it's reporting syntax error.

Replies are listed 'Best First'.
Re^3: How does the built-in function length work?
by chromatic (Archbishop) on Feb 10, 2012 at 02:23 UTC

    You need something like this before you can use named Unicode characters:

    use charnames ':full';

    Improve your skills with Modern Perl: the free book.

Re^3: How does the built-in function length work?
by ikegami (Patriarch) on Feb 12, 2012 at 04:04 UTC

    By syntax error, do you mean the following?

    Constant(\N{LATIN CAPITAL LETTER E WITH ACUTE}ric) unknown: (possibly +a missing "use charnames ...") at - line 1, within string Execution of - aborted due to compilation errors.

    If so, like the message says, it's because you need to add use charnames ':full';. If not, could you be more specific? Maybe your version of Perl predates \N{}?

    PS — charnames will be loaded automatically when needed in 5.16.