Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Seussian Perl

by hdb (Monsignor)
on Apr 10, 2013 at 21:17 UTC ( [id://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 (Canon) 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__ one.fish 1 blue.fish -20 one.fish 0 blue.fish -1 blue.fish 0 fish-red. +fish ,and one.fish 2
    package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

      Small proposal:

      @hat=split/ /,<<THAT; one.fish 1 blue.fish -20 one.fish 0 blue.fish -1 blue.fish 0 fish-red. +fish ,and one.fish 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 @ swedger.org TSBMMAR

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (8)
As of 2024-04-24 10:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found