PDA

View Full Version : Script quits executing nested loop randomly


smeshy123
02-29-2008, 06:12 PM
About a quarter of the way of going through my two text files, the script stops executing the nested loop and just finishes going through the outside loop. I have no idea why this is happening. I'm new to perl so be gentle!

PS: Pretend *** is the name of the real variable. Apparently my variable name is being cencored. It is a truncation of assignment.


foreach $*** (@***_data) {
chop ($***);
($***_a,$***_hn,$***_n,$***_rdc)=split(' ',$***);
#set up boundaries
$x_min = $***_hn - $x_sen;
$x_max = $***_hn + $x_sen;
$y_min = $***_n - $y_sen;
$y_max = $***_n + $y_sen;
$j = 0;
print "$x_min, $x_max \n";
foreach $cs (@cs_data) {
chop ($cs);
($hn_1, $hn_2, $hn_3, $hn_4, $hn_5, $hn_6, $hn_7, $hn_8, $hn_9) = split(' ',$cs);
if ($hn_5 = "H" && $hn_6 = "H" && $hn_7 < $x_max && $hn_7 > $x_min) {
$k = 0;
print "$***_a, $hn_7 \n";
}
}
}

KevinADC
02-29-2008, 06:57 PM
no way to tell without seeing some of the data the script is processing. But, generally, the problem is a false assumption by the user/programmer, or a flaw in the logic of the program, that is the source of the problem. Put some print lines in your code and watch it while it runs and see if you spot whats going on.

uatt
03-03-2008, 02:05 PM
How about change this
if ($hn_5 = "H" && $hn_6 = "H"....
to
if ($hn_5 eq "H" && $hn_6 eq "H"