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

Re^3: Parse file and creating hashes

by tybalt89 (Monsignor)
on Jan 08, 2022 at 17:55 UTC ( [id://11140274]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Parse file and creating hashes
in thread Parse file and creating hashes

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11140267 use warnings; my %answer; while( <DATA> ) { my (undef, $two, $three) = split /,|\n/; $answer{$three}{$two}++; } my $thirty = 1; # FIXME 1 for testing, should be 30 for my $href ( values %answer) { delete @{$href}{ grep $href->{$_} <= $thirty, keys %$href } } delete @answer{ grep 0 == %{ $answer{$_} }, keys %answer }; $_ = [ keys %$_ ] for values %answer; use Data::Dump 'dd'; dd \%answer; __DATA__ 702005010683593,5016683593,7020000024140 702005010640383,5016640383,7020000024150 310005010532143,5016532143,7020000034001 702005010637702,5016637702,7020000034001 702005010608274,5016608274,7020000034013 702005010608274,5016608274,7020000034013 310005010609604,5016609604,7020000034013 702005010510869,5016510869,7020000034013 702005010551513,5016551513,7020000034130 702005010551513,5016551513,7020000034130 702005010679719,5016679719,7020000034222 702005010527052,5016527052,7020000034222 702005010645458,5016645458,7020000034222

Outputs:

{ "7020000034013" => [5016608274], "7020000034130" => [5016551513] }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-03-28 13:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found