|
|
|
Clear questions and runnable code get the best and fastest answer |
|
| PerlMonks |
Re: Test for the last element in a foreach (==\)by tye (Sage) |
| on Aug 02, 2007 at 20:16 UTC ( [id://630384]=note: print w/replies, xml ) | Need Help?? |
|
Since you said "array", you can use \$_ == \$array[-1]:
Update: ikegami asked about Data::Alias being able to confuse this test. Yes, that can be done, and one can even do it w/o such a module but it requires some unusual contortions and so probably isn't something to worry too much about:
- tye
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||