in reply to Re^2: find position of element of array
in thread find position of element of array
Just check for the returned index being 0 and handle that special case appropriately. Negative indexes count backwards, so in your above array $a[-1] will correctly return "e". $a[5] will be undef, because the array only contains values for @a[0..4]. Take a look at perldoc perldata for more details on arrays.
BTW, you should add <code></code> tags around the code in your posts, otherwise it comes out mangled.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: find position of element of array
by perlbeginner10 (Acolyte) on Nov 13, 2005 at 12:14 UTC |