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

RE: [FWP] Fun With Golf



How about:

sub fifth_word{@a=split(/ /,$_[0]);$a[4]}

> -----Original Message-----
> From: owner-fwp@technofile.org [mailto:owner-fwp@technofile.org]On
> Behalf Of Jeff Pinyan
> Sent: Wednesday, October 18, 2000 7:31 AM
> To: Ronald J Kimball
> Cc: fwp@technofile.org
> Subject: Re: [FWP] Fun With Golf
> 
> 
> On Oct 18, Ronald J Kimball said:
> 
> >  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.
> 
> Here's my try.  Start AFTER the opening {, please.
> 
>   sub fifth_word {my$a=pop;s/(\w+)// for 1..5;$1}
>             start^                              ^end
> 
> -- 
> Jeff "japhy" Pinyan     japhy@pobox.com     http://www.pobox.com/~japhy/
> PerlMonth - An Online Perl Magazine            http://www.perlmonth.com/
> The Perl Archive - Articles, Forums, etc.    http://www.perlarchive.com/
> CPAN - #1 Perl Resource  (my id:  PINYAN)        http://search.cpan.org/
> 
> 
> ==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
> ==== Send email to <fwp-request@technofile.org> with message _body_
> ====   unsubscribe
> 

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