Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: How does the built-in function length work?

by PerlOnTheWay (Monk)
on Feb 10, 2012 at 01:37 UTC ( [id://952902]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://952902]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-04-20 03:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found