[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Fun With Golf



On 18/10/2000 14:49:31 Ronald J Kimball  wrote:

>
>  Write a Perl subroutine which returns the fifth word in a string. A word
>  is any sequence of letters, numbers, and/or underscores. The string will
>  be passed as the sole argument and will contain at least 5 words.
>


This was my first try:
     sub fifth_word{$_=shift;(split)[4]}
     That's 19 strokes inside.

Ooops!

sub fifth_word{$_=pop;(split)[4]}
That's 17 :-)

Csaba



--
Csaba Raduly,    Software Developer (OS/2),    Sophos Anti-Virus
csaba.raduly@sophos.com                   http://www.sophos.com/
US Support +1 888 SOPHOS 9            UK Support +44 1235 559933
Life is complex, with real and imaginary parts.



==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe