in reply to Perl - write data from hashes

Mr. aitap I tested your snippet, without modification it would give away
"Modification of a read-only value attempted at" error
nevertheless that snippet of yours is a beautiful code mate
and here i'm using it
thank you
and here the complete script for the author, it processes 4 files in a loop
files are named file1-4
for ($i = 1; $i < 5; $i++){ $a[$i]{'name'} = "file$i"; open IN, "<file$i" or die $!; while(<IN>){ if (/(\w)\t(\w)\t([\d\.]+)/){ $a[$i]{"$1$2"} = $3; $a[$i]{'total'} = sprintf('%.2f', $a[$i]{'total'}+=$3) +; } } close(IN); } foreach $key ('name', grep {$_ ne 'name'} sort keys $a[1]){ print join "\t", $key, map($_->{$key}, @a[1..4]),"\n"; }
and output:
name file1 file2 file3 file4 AB 12.00 01.00 02.00 62.00 CD 13.00 04.00 03.00 43.00 EF 11.00 42.00 15.00 24.00 GH 22.00 34.00 20.00 26.00 total 58.00 81.00 40.00 155.00
files which are used, created from the author's output:
~@deb:~/perl/9# cat file1 A B 12.00 C D 13.00 E F 11.00 G H 22.00 ~@deb:~/perl/9# cat file2 1 A B 01.00 2 C D 04.00 3 E F 42.00 4 G H 34.00 ~@deb:~/perl/9# cat file3 A B 02.00 C D 03.00 E F 15.00 G H 20.00 ~@deb:~/perl/9# cat file4 1 A B 62.00 2 C D 43.00 3 E F 24.00 4 G H 26.00