rsriram has asked for the wisdom of the Perl Monks concerning the following question:

Hi

I want to increase the value of a variable in terms of alphabets. That is, if $num has the value A, $num++ should store B and so on. Is there any way to acheive this?

Replies are listed 'Best First'.
Re: Incrementing a variable alphabetically
by rpanman (Scribe) on Jul 19, 2007 at 10:52 UTC
    Hi rsriram

    You can do this exactly as you have said...
    $a="a"; $a++; print $a; # prints b
      This has to be one of the weirdest things I've ever seen about perl. I had no idea. I feel as if I just found out my wife is really a brunette.
        Hee hee. Dragged this up:

        perl -le 'for($c="McD"; $i<167990; $i++, $c++) {} print $c'
Re: Incrementing a variable alphabetically
by lima1 (Curate) on Jul 19, 2007 at 11:20 UTC