in reply to Shortest -return index of element in array- sub
Good Day,sub find { 1 while $_[0]ne pop; $#_+1?(&a(@_),$#_):(); } my @array=('john','paul','ringo','george', 'ringo'); print &find('john',@array),"\n"; # Returns 0 print &find('ringo',@array),"\n"; # Returns 24 print &find('mick',@array),"\n"; # Returns undef
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Shortest -return index of element in array- sub
by MeowChow (Vicar) on Mar 24, 2001 at 23:59 UTC | |
|
Re: Re: Shortest -return index of element in array- sub
by MrNobo1024 (Hermit) on Apr 02, 2001 at 04:41 UTC |