perl - simple array syntax problem
I'm trying to declare all the lowercase letters in the alphabet in an array, so then I can call on 'a' as '1' and 'c' as '3', etc...
This doesn't seem to work... @lwralphabet=qw/JUNK ['a'..'z']/; print $lwralphabet[3]; |
Try using:
@lwralphabet=('a'..'z'); print $lwralphabet[3]; Also remember that the first item in an array is at "0" so a=0. |
that works, thanks..
I was trying to get it to get the values + 1 by using a JUNK value.. however, this will suffice |
If you really want "a" to be one then you can use:
@lwralphabet=('Z','a'..'z'); This will make Z=0 and a=1 |
All times are GMT -5. The time now is 06:02 PM. |