foreach (@totalExoda) { $sum += $_; } #### foreach my $x (@totalExoda) { $sum += $x; } #### sub Esoda_Statistika_button { my $sum = 0; chdir "/home/props/delice/eksoda" or die "didn't make to eksoda folder\n"; foreach my $file (glob '*.txt') { open my $in, "<", $file; while (<$in>) { $sum += $1 if /Exoda.*Total:(.*\d)/; } } return $sum; } #### echo "whatever" > "/home/props/delice/eksoda/| rm *"