Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://311569]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (10)
As of 2017-07-24 13:40 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (354 votes). Check out past polls.