in reply to Array Fun

phantom20x++

Nifty stuff!

Are you up for a challenge? Try replacing your first while loop with

push @list, grep{/\S/} split '' while <>;
What's going on there? Have a look at split and grep and see if you can work it out. Get back to us if you need a pointer.

Happy Perling!

Replies are listed 'Best First'.
Re^2: Array Fun
by phantom20x (Acolyte) on Apr 06, 2007 at 17:50 UTC
    Thanks, thats really cool. Haven't looked into split or grep, but it seems like quite a bit can be done with them. So in this case you use grep to pattern search for any non-whitespace character and then it splits them. Still trying to understand split but I think I get the grep part.
Re^2: Array Fun
by xiaoyafeng (Deacon) on Apr 19, 2007 at 03:57 UTC
    don't forget map and sort beside split and grep. ;)
    my @list2 = map {$_[0]} sort {$b[1] <=> $a[1]} map {[$_,rand]} @list;