Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Seussian Perl

by hdb (Prior)
on Apr 10, 2013 at 21:17 UTC ( #1028045=poem: print w/replies, xml ) Need Help??

Better version than under Re: Need Help in processing a file

use strict; # just kidding my%hat;my@cat=split/ /,<DATA>; while(@cat){ my($cat=>$hat)=splice@cat,0,2; $hat{$cat}=$hat>$hat{$cat}?$hat:$hat{$cat}; } print join" ",%hat; # and that was that __DATA__ a.txt 4 b.txt 3 z.txt 1 a.txt 5 b.txt 2 b.txt 4 z.txt 2

Replies are listed 'Best First'.
Re: Seussian Perl
by tobyink (Abbot) on Apr 11, 2013 at 09:02 UTC
    use v5.10; @hat=split/ /,<DATA>; while(@hat){ ($hat=>$littlecat)=splice@hat,0,2; $littlecat{$hat}=$littlecat>$littlecat{$hat}?$littlecat:$littlecat{$ +hat}; } say+join" ",map"$_ $littlecat{$_}",sort{$littlecat{$b}<=>$littlecat{$a +}}keys%littlecat; __DATA__ 1 -20 0 -1 0 fish-red. +fish ,and 2
    package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

      Small proposal:

      @hat=split/ /,<<THAT; 1 -20 0 -1 0 fish-red. +fish ,and 2 THAT

      instead of __DATA__ segment. Thanks a lot for adding Seussian data!

Re: Seussian Perl
by swedger (Initiate) on Jul 29, 2013 at 12:22 UTC
    I liked it. Very cool and better than i could have done. Peace Billy @ TSBMMAR

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: poem [id://1028045]
Approved by marto
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2016-10-26 11:36 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (340 votes). Check out past polls.