Jeff Pinyan wrote: > > 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 that doesn't work, and s/my\$a/\$_/ won't fix it. here's my first try: sub fifth_word {$_=pop;s/^\W+//;(split/\W+/)[4]} -- Steve Lane <sml@zfx.com> ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe