Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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 (Chancellor) 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?
[Tanktalus]: yeah, I saw you post about MCE - the concept looks really really cool. I wonder how well it plays with Coro :)
[Lady_Aleena]: Hi guys. I asked this earlier but got no answer. Why is this dying at -exec: my @music_times = qx(find ~/Music/Albums/ -type f -iname '*.mp3' -exec mp3info -p "%S\n" {} \;);
[Lady_Aleena]: The error find: missing argument to `-exec'
[Discipulus]: Tanktalus we will be glad to have you here more frequently, tho ;=)
[marioroy]: Lady_Aleena oh I thought you found the error by adding -exec mp3info
[Tanktalus]: Discipulus: I should be working on an interview test right now. Well, I kind of am, but keep getting myself distracted :)
[Lady_Aleena]: marioroy, nope, that IS the error.
[Discipulus]: oh to be distracted PM is still a wonderfull place

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2017-04-23 19:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (432 votes). Check out past polls.