Mandar,
You can simply de-reference the array!
[code]
my $list=['orange','red','purple'];
foreach(@$list) {
print $_."\n";
}
[/code]
By saying @$list, you turn an array reference
into an array, for purposes of the loop.
Love those references!
$trooper
16-Aug-2004 18:23 PST
======================
-----Original Message-----
From: Mandar Rahurkar [mailto:[EMAIL PROTECTED]
Sent: Monday, August 16, 2004 14:32
Cc: [EMAIL PROTECTED]
Subject: accessing each element
Hi,
I have a list ,
$list=['orange','red','purple'];
How do I access each member of $list ? If this had been @list I cud have
done,
foreach(@list) {
print $_;
}
How does it work for a scalar ?
Thanks,
Mandar
--
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional
commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/>
<http://learn.perl.org/first-response>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>