sub Esoda_Statistika_button { my @totalExoda = (); my $sum = 0; my $clearedValue=0; chdir "/home/props/delice/eksoda" or die "didn't make to eksoda folder\n"; foreach my $file (glob '*.txt') { open IN, $file; while () { if ($_ =~ m/(Exoda.*Total:)(.*\d)/) { $clearedValue =$2; push(@totalExoda,$clearedValue); } #if } #end while } #end outer foreach foreach (@totalExoda){ $sum+= $_; } #end inner foreach chomp $sum; print "$sum\n"; } #end sub