> From: Csaba Raduly [mailto:csaba.raduly@sophos.com] > Sent: Wednesday, October 18, 2000 10:21 > To: fwp@technofile.org > Subject: 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 :-) But neither of them meets the specification, which you graciously copied above. "What's the fifth word in this string?" The correct answer according to the specification is "word", but your code gives "in". -- Larry Rosler Hewlett-Packard Laboratories http://www.hpl.hp.com/personal/Larry_Rosler/ lr@hpl.hp.com ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe