Hi again. When I run your script it works fine, but when I try to call a text file from the directory where the data is previously stored I get the "bad data" error. Is there something I changed which is causing this error? How can I use the data from a called text file?
#!/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;