Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Re: rearranging text

by l2kashe (Deacon)
on Dec 02, 2003 at 09:59 UTC ( #311569=note: print w/ replies, xml ) Need Help??


in reply to Re: rearranging text
in thread rearranging text

This leads to possibly ugly output as there will be an extra comma in the output

Also will a value appear more than once, and should the values be sorted as well? Im thinking a HoH might be overkill, but another (better?) way to do it.

my %all; while (<>) { s/\s+//g; my($k, $v) = split /,/; next unless defined $k and defined $v; $all{$k}{$v}++; } for ( sort keys %all ) { print "$_, ", join(', ', sort keys %{ $all{$_} }), "\n"; }

use perl;


Comment on Re: Re: rearranging text
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (19)
As of 2015-07-28 20:47 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 (258 votes), past polls