Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
P is for Practical
 
PerlMonks  

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

by PerlOnTheWay (Scribe)
on Feb 10, 2012 at 01:37 UTC ( #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.


Comment on Re^2: How does the built-in function length work?
Download Code
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 (Pope) 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
Node Status?
node history
Node Type: note [id://952902]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2014-04-20 18:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (486 votes), past polls