In article <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] wrote:
> On Dec 13, Jenda Krynicky said:
> > $num = ord($char) - ord('A') + 1
> >or if you do it often
> >
> > my $char_base = ord('A') - 1;
> > ...
> > $num = ord($char) - $char_base;
> No benefit to that, really. ord('A') is
On Dec 13, Jenda Krynicky said:
> $num = ord($char) - ord('A') + 1
>
>or if you do it often
>
> my $char_base = ord('A') - 1;
> ...
> $num = ord($char) - $char_base;
No benefit to that, really. ord('A') is calculated at compile-time, not
run-time.
--
Jeff "japhy" Piny
From: "Collins, Joe (EDSI\\BDR)" <[EMAIL PROTECTED]>
> How can I convert the scalar 'A' (or 'a') to 1, 'B' to 2 and so on?
> Related: how do I get the true internal value for A, i.e. ascii
> value?
$num = ord($char) - ord('A') + 1
or if you do it often
my $ch
--- "Collins, Joe (EDSI\\BDR)" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> How can I convert the scalar 'A' (or 'a') to 1, 'B' to 2 and so on?
my %alpha_to_num;
@alpha_to_num{ A .. Z } = ( 1 .. 26 );
print $alpha_to_num{ A };
> Related: how do I get the true internal value for A, i.e. ascii value?