> > 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]}; This one ok? > > -- > 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