use strict; use warnings; use PDL; use PDL::IO::Misc; use PDL::NiceSlice; open my $in, '<', 'BN_Fc_26_Ac_8.dat' or die "Can't read old file: $!"; open my $out, '>', 'datosF26A8.txt' or die "Can't write new file: $!"; my %s; my %rms; my $c; { while(<$in>){ next if /^\#/; my @datos=split; my $a=sprintf("%.1f",$datos[4]); my $f=sprintf("%.1f",$datos[5]); $s{$a}{$f}=$datos[0]; $rms{$a}{$f}=$datos[1]; } foreach my $amp (sort {$a <=> $b} keys %s){ foreach my $frq (sort {$a<=>$b} keys %{$s{$amp}}){ say $out join " ",$amp,$frq,$s{$amp}{$frq},$rms{$amp}{$frq};} say $out; } } ($c) =PDL->rcols'datosF26A8.txt',[]; print $c;