in reply to Re^3: Parse file and creating hashes
in thread Parse file and creating hashes
#!/usr/bin/perl -w use strict; # https://perlmonks.org/?node_id=11140267 use warnings; use Data::Dumper qw(Dumper); my $dir = "/home/vlr/archive/"; my $file = $dir."temp.txt"; 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; } open my $FH, '>', 'output.txt'; print $FH Dumper(\%answer); close $FH;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Parse file and creating hashes
by tybalt89 (Monsignor) on Jan 09, 2022 at 00:33 UTC | |
|
Re^5: Parse file and creating hashes
by tybalt89 (Monsignor) on Jan 08, 2022 at 23:53 UTC |