in reply to Re^2: Parse file and creating hashes
in thread Parse file and creating hashes
Here's another way...
#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11140267 use warnings; my $file = <<END; 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 END open my $fh, '<', \$file or die; # FIXME change for your file my $thirty = 1; # FIXME 1 for testing, should be 30 my (%answer, %lines); $lines{ /,(.+)/ ? $1 : die "bad data <$_>" }++ while <$fh>; for ( keys %lines ) { my ($value, $key) = split ','; $lines{$_} > $thirty and push @{ $answer{$key} }, $value; } use Data::Dump 'dd'; dd \%answer;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Parse file and creating hashes
by PerlMonger79 (Sexton) on Jan 08, 2022 at 22:13 UTC | |
by LanX (Saint) on Jan 08, 2022 at 22:22 UTC | |
|
Re^4: Parse file and creating hashes
by PerlMonger79 (Sexton) on Jan 08, 2022 at 22:52 UTC | |
|
Re^4: Parse file and creating hashes
by PerlMonger79 (Sexton) on Jan 09, 2022 at 00:36 UTC | |
by tybalt89 (Monsignor) on Jan 09, 2022 at 00:58 UTC | |
|
Re^4: Parse file and creating hashes
by PerlMonger79 (Sexton) on Jan 08, 2022 at 23:49 UTC | |
by tybalt89 (Monsignor) on Jan 09, 2022 at 00:33 UTC | |
by tybalt89 (Monsignor) on Jan 08, 2022 at 23:53 UTC | |
|
Re^4: Parse file and creating hashes
by PerlMonger79 (Sexton) on Jan 09, 2022 at 01:09 UTC | |
by tybalt89 (Monsignor) on Jan 09, 2022 at 02:15 UTC |