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

Re: [FWP] Fun With Golf



Today around 12:58pm, Joey Mitchell Comeau hammered out this masterpiece:

: 
: > >  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
: 
: Here's mine.
: 
:       sub fifth($) {(split(/\W/,shift))[4]};

       sub fifth    {(shift=~/(\w+)/g)[4]}

--
print(join(' ', qw(Casey R. Tweten)));my $sig={mail=>'crt@kiski.net',site=>
'http://home.kiski.net/~crt'};print "\n",'.'x(length($sig->{site})+6),"\n";
print map{$_.': '.$sig->{$_}."\n"}sort{$sig->{$a}cmp$sig->{$b}}keys%{$sig};
my $VERSION = '0.01'; #'patched' by Jerrad Pierce <belg4mit at MIT dot EDU>


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