Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: compound statement

by props (Hermit)
on Oct 07, 2007 at 10:30 UTC ( [id://643248]=note: print w/replies, xml ) Need Help??


in reply to Re: compound statement
in thread compound statement

I really appreciate your help on this this is a sample txt file with content:
Supplier1 1 Supplier2 2 Supplier3 3 Exoda Total:6 euros
i need to get from every input file that Total:6 euros ( The number 6 in this case). The logic behind it is that i need to add my daily shop expenses in a file everyday. So whenever i want to check my monthly or yearly expenses to run this subroutine and get the total expenses. So i need one number but i do something wrong i get the following output:
0 0 0 0 0 0 0 0 0 6 6 12 12 18 18 24 24 30 30 36 36 42 42 48 48 54 54 60 66 66 72 78 78 84 90 90 96 102 102 108 114 114 120 126 126 132 138 138 144 150 150 156 162 162 168 174 274
there is a confusion somewhere

Replies are listed 'Best First'.
Re^3: compound statement
by props (Hermit) on Oct 07, 2007 at 13:39 UTC
    well this code works for me
    sub Esoda_Statistika_button { my @totalExoda = (); my $sum = 0; my $clearedValue=0; chdir "/home/props/delice/eksoda" or die "didn't make to eksoda folde +r\n"; foreach my $file (glob '*.txt') { open IN, $file; while (<IN>) { 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
    this thing stresses my head :)
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://643248]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-20 03:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found