Mailinglist Archive: opensuse (2532 mails)
| < Previous | Next > |
Re: [opensuse] Quick perl question - why are @array[$num] and $array[$num] the same?
- From: Sam Clemens <clemens.sam1@xxxxxxxxx>
- Date: Thu, 01 May 2008 03:36:41 -0400
- Message-id: <48197309.5020700@xxxxxxxxx>
David C. Rankin wrote:
I gave up on perl.
It makes my brain hurt -- like trying to read 1970's era BASIC code.
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx
Listmates:
I don't know who I have to thank for this, but I think it was Anders who recommended that I look at perl after one of my last weird bash questions. I have a syntax question as I go though perl.
The situation. I read a file into an array and then go to reference each line.
my $NUM = 1;
open FILE, ".bashrc" or die $!;
my @array = <FILE>;
How is it legal that I can reference the array element either as @array[element] or $array[element]?:
while (@array[$NUM]) {
print "$NUM : @array[$NUM]\n";
$NUM++;
}
while ($array[$NUM]) {
print "$NUM : $array[$NUM]\n";
$NUM++;
}
From what I've read, it seems like the list $array[element] would just return the number of characters in the list $array[element] not the text itself. How should I think about this?
I gave up on perl.
It makes my brain hurt -- like trying to read 1970's era BASIC code.
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx
| < Previous | Next > |