### Thread: Problem In For Loop (logic Problem )

1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
May 2013
Posts
1
Rep Power
0

#### Problem In For Loop (logic Problem )

for example

input file

.

'

'

if (y-a)&&(z-c)< threshold

print as following

<CODE>
use strict;
use warnings;

my \$JOB = \$ARGV[0];
my \$threshold = \$ARGV[1];

my @file_array;

while (my \$line = <INFILE_link>) {
chomp \$line;
my @line_array = split(/\s+/, \$line);
push (@file_array, \@line_array);
}

my \$ix=1;
my (\$i, \$a, \$b, \$c, \$d, \$x, \$w, \$y, \$z, \$ta, \$tb, \$tc, \$td);

\$a= \$b= \$c= \$d= \$x= \$w= \$y= \$z= \$ta = \$tb =\$tc =\$td= 0;
#open (FILE,'>'."\$fh");
{
\$ta = \$file_array[\$i][2];
\$tb = \$file_array[\$i][3];
\$tc = \$file_array[\$i+1][2];
\$td = \$file_array[\$i+1][3];

if (\$a=\$b=\$c=\$d=\$x=\$w=\$y=\$z = 0)
{

\$a = \$x = \$ta ;
\$b = \$y = \$tb ;
\$c = \$w = \$tc ;
\$d = \$z = \$td ;
last;
}
if ( (\$ta-\$a) < \$threshold && (\$tc-\$c) < \$threshold)
{
# copy tabcd to abcd
\$a = \$ta ;
\$b = \$tb ;
\$c = \$tc ;
\$d = \$td ;
}
else
{

print "\$file_array[\$i][0] \$file_array[\$i][2] \$file_array[\$i+2]
+[3]\n\$file_array[\$i+1][0] \$file_array[\$i+1][2] \$file_array[\$i+3][3]\n
+";

\$a = \$x = \$ta ;
\$b = \$y = \$tb ;
\$c = \$w = \$tc ;
\$d = \$z = \$td ;

}
} # end of for loop

if (\$a=\$b=\$c=\$d=\$x=\$w=\$y=\$z != 0)
{

print "\$file_array[\$i][0] \$file_array[\$i][2] \$file_array[\$i][3
+]\n\$file_array[\$i+1][0] \$file_array[\$i+1][2] \$file_array[\$i+1][3]\n";

</CODE>

MY INPUT

MVRS has asked for the wisdom of the Perl Monks concerning the following question:
Reputation: 3
hi friends , here a perl script written by me to merge link files

OUTPUT

I FOUND HERE IN THE FOR LOOP THE LOOP EXCEEDS BEYOND THE LOOP VALUE , CAN SOME BODY HELP ME FIXING THIS LOGIC
2. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
May 2013
Posts
1
Rep Power
0

#### Problem In For Loop

Alright so we're working on a school assignment and we have to make a roller coaster. the problem is the loop pinches and the marble rolls and either sticks or falls back the other way.