Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Need Help in processing a file

by hdb (Prior)
on Apr 10, 2013 at 20:31 UTC ( #1028037=note: print w/ replies, xml ) Need Help??


in reply to Need Help in processing a file

Some Perl Poetry for You:

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

Now you only need to sort out the sorting...

UPDATE under Seussian Perl


Comment on Re: Need Help in processing a file
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1028037]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2015-07-30 02:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls