props has asked for the wisdom of the Perl Monks concerning the following question:
# the above logic is wrong because of its mistaken result, can you solve this algorithm ?sub Esoda_Statistika_button { my @totalExoda = 0; my $sum = 0; my $clearedValue=0; chdir "/home/props/delice/eksoda" or die "didn't make to eksoda folde +r\n"; #for every txt file in the directory foreach my $file (glob '*.txt') { # open that file open IN, $file; # read through that file line by line while (<IN>) { #if matches a digit at the specific form if ($_ =~ m/(Exoda.*Total:)(.*\d)/) { #pick that number and store it in $2 $clearedValue =$2; #add all these matched values to @totalExoda push(@totalExoda,$clearedValue); } #end while # sum up numbers of @totalExoda and store it in $sum; foreach (@totalExoda){ $sum+= $clearedValue; print "$sum\n"; } #end if } #end foreach } #end foreach } #end sub
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: compound statement
by FunkyMonk (Bishop) on Oct 07, 2007 at 08:57 UTC | |
| |
|
Re: compound statement
by jeanluca (Deacon) on Oct 07, 2007 at 08:51 UTC | |
|
Re: compound statement
by moritz (Cardinal) on Oct 07, 2007 at 09:00 UTC | |
|
Re: compound statement
by quester (Vicar) on Oct 07, 2007 at 09:11 UTC | |
by FunkyMonk (Bishop) on Oct 07, 2007 at 10:13 UTC | |
by ysth (Canon) on Oct 07, 2007 at 19:41 UTC | |
by props (Hermit) on Oct 07, 2007 at 10:30 UTC | |
by props (Hermit) on Oct 07, 2007 at 13:39 UTC | |
| |
| A reply falls below the community's threshold of quality. You may see it by logging in. | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |