Beefy Boxes and Bandwidth Generously Provided by pair Networks Ovid
We don't bite newbies here... much
 
PerlMonks  

Re: Shortest -return index of element in array- sub

by ChOas (Curate)
on Mar 21, 2001 at 18:37 UTC ( #66026=note: print w/ replies, xml ) Need Help??


in reply to Shortest -return index of element in array- sub

I think I forgot to show Leon this one ;))
works with strict, and -w

sub indexArray { 1 while $_[0] ne pop; @_-1; }

Side node to Arhuman (see below): Respect goes out to you man! ;))

GreetZ!,
    ChOas

print "profeth still\n" if /bird|devil/;


Comment on Re: Shortest -return index of element in array- sub
Download Code
Re: Re: Shortest -return index of element in array- sub
by arhuman (Vicar) on Mar 21, 2001 at 19:10 UTC
    sub indexArray(@) { 1 while $_[0] ne pop; $#_; }
    Saves One char...
    Could be applied to some of the other solutions (jmcnamara) too...


    "Trying to be a SMART lamer" (thanx to Merlyn ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://66026]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2014-04-21 02:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (489 votes), past polls