http://www.perlmonks.org?node_id=1069490


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 )

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