For Programmers: Free Programming Magazines  


Home > Archive > PERL Programming > December 2005 > charCodeAt









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author charCodeAt
secret

2005-12-29, 6:25 am

Hey all u perl guys, I'm a newbie . So excuse a dumb question like this.
I just wanna know how to get the ascii value of a char
like
a->97
A->65
Let me put it this way, i wanna know how to run the javascript funcation "charCodeAt" in perl.

Example:
// 0123456789012345678901234567890123456789
01 var s = "See the brown dog chase the fat black cat."; Response.write(s.charCodeAt(14)); Response.write(s.charCodeAt(42));

The example produces the following output.
100 0

thx in advance.
displeaser

2005-12-30, 4:38 am

Hi,

use the ord command.

print ord('A'); #prints 65


to get more details on the command try:

Perldoc -f ord


Hope this helps.
Displeaser
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com