Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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

Comment on Seussian Perl
Download Code
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__ 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
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? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2014-09-20 01:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (151 votes), past polls