Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: Not getting desire output by using switch statement in Perl

by rammohan (Acolyte)
on Jan 06, 2014 at 11:53 UTC ( #1069490=note: print w/replies, xml ) Need Help??


in reply to Re: Not getting desire output by using switch statement in Perl
in thread Not getting desire output by using switch statement in Perl

Then how I'm achieve that result?(me question is if I give a string then it returns output result with numeric values like based on alphabetic value in numeric type- a is 1, b is 2,c is 3 in this similar way up to..... z is 26 )
  • Comment on Re^2: Not getting desire output by using switch statement in Perl

Replies are listed 'Best First'.
Re^3: Not getting desire output by using switch statement in Perl
by choroba (Bishop) on Jan 06, 2014 at 12:11 UTC
    Easy. See ord:
    if ($a =~ /[a-z]/) { print ord($a) - 96; } else { print "Everything else"; }
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1069490]
help
Chatterbox?
[oiskuu]: marto, it ended badly? I doubt the power is easy to plug at those installations?
[marto]: oiskuu sadly yes
[Your Mother]: My cat used to climb into the freezer when I opened it. Once I closed it and left him for 5 minutes hoping to disuade the habit. When I opened it expecting a cat eager to never return he just stared at me. Had to pull him out.
[Your Mother]: oiskuu, I think we should just be friends.
[marto]: the 'cool' place to hang out
[Your Mother]: ♫ Caffeine, caffeine, caffeine, caffeine. There will be answer, caffeine. ♫ ♬
[oiskuu]: Ahh, old cats with rheuma. I think (s)he was saying, "dude, NOT cold enough."

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (13)
As of 2017-12-18 15:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (488 votes). Check out past polls.

    Notices?