in reply to how to make variable forget its previous value?
Hi,
Note i am not sure about what you asked us exactly may be if this code is wrong i am sorry about that
Update sorry about the above code i din notice the while loop in between so make this alteration
use List::Util qw/ min max sum /; $a = -55; $b = -54; $c = -55; $d = -54; for (1..110)# Start your loop { $file = "x_$a\_to_$b\_y$c\_to_$d";#file name open(INFILE,"<","$file") or die("Couldn't open file for reading!\n"); while(<INFILE>){ push @column8,(split(/\s+/,$_))[7];##Push data to array } if(@column8)## if array is not empty then it will go inside { $ZMAX = max @column8; print "maxZ $ZMAX\n"; $ZMIN = min @column8; print "minZ $ZMIN\n"; $thick = $ZMAX - $ZMIN; print "$thick\n"; } ## Once the values are printed this will help you to erase the previou +s values of $ZMAX, $ZMIN, $thick, @column8 for your second file $ZMAX=""; $ZMIN=""; $thick=""; @column8=(); $c++; $d++; ## Note this loop will run for 110 times so it seems you should have 1 +10 files when you increment $c++ and $d++; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to make variable forget its previous value?
by AnomalousMonk (Archbishop) on Jan 03, 2012 at 10:56 UTC |