Yep, just leave off the "$element" from the statement you wrote. Then you
can use $_ for the current element.
Example:
@array = ("first", "second", "third", "fourth");
foreach (@array) {
print "$_\n";
}
would print
first
second
third
fourth
- Alan
-----Original Message-----
From: Sturdevant-Contractor, Robert W
[mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 19, 2002 13:45
To: [EMAIL PROTECTED]
Subject: Special Name for @ Element
Hi all,
Is there a special name (like $_) to identify the array element being
addressed as in the following code:
foreach $element (@array) { do something };
In other words, the above iterates thru the array finding elements
$array[0..n]. Can I tell the specific element being enumerated using a perl
special name? Obviously an index counter will do the trick but a perlish way
would be cool. Thanks.
Bob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]