LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-09-2004, 12:44 AM   #1
lrt2003
Member
 
Registered: Mar 2004
Distribution: Fedora 10
Posts: 182

Rep: Reputation: 30
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];
 
Old 05-09-2004, 05:40 AM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Try using:
@lwralphabet=('a'..'z');
print $lwralphabet[3];

Also remember that the first item in an array is at "0" so a=0.
 
Old 05-09-2004, 06:58 AM   #3
lrt2003
Member
 
Registered: Mar 2004
Distribution: Fedora 10
Posts: 182

Original Poster
Rep: Reputation: 30
that works, thanks..

I was trying to get it to get the values + 1 by using a JUNK value.. however, this will suffice
 
Old 05-09-2004, 01:35 PM   #4
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
If you really want "a" to be one then you can use:
@lwralphabet=('Z','a'..'z');

This will make Z=0 and a=1
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
(linking?) problem compiling very simple array class btb Programming 3 08-02-2005 03:16 PM
What does the syntax-- $ENV{'REMOTE_HOST'} --mean in Perl? Bassam Programming 3 03-31-2004 07:54 AM
Perl system function syntax Crashed_Again Programming 2 03-20-2004 04:00 AM
PERL: Size of an array of an Array inspleak Programming 2 03-10-2004 02:24 PM
perl syntax jenny_psion Programming 2 08-13-2003 12:23 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration