|
|
| Do you know where your variables are? | |
| PerlMonks |
Re: sort arrayby jwkrahn (Prior) |
| on Apr 30, 2012 at 20:00 UTC ( #968141=note: print w/ replies, xml ) | Need Help?? |
|
You say you want the third word from the left but you are accessing the third word from the right. $words[ scalar( @words ) - $word_level ] should be $words[ $word_level - 1 ]. But you are not actually getting a word because split( /\s+/) is short for split( /\s+/, $_) and you don't have a value in $_ to split on. So you want something like this:
You don't need a foreach loop, you can just do:
And instead of calling a subroutine in the sort block you could just use the subroutine name:
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||