Your skill will accomplishwhat the force of many cannot PerlMonks

### Re^6: problem in for loop

by MVRS (Acolyte)
 on May 16, 2013 at 08:31 UTC ( #1033788=note: print w/replies, xml ) Need Help??

in reply to Re^5: problem in for loop
in thread problem in for loop

threshold=1000

Input

output

Replies are listed 'Best First'.
Re^7: problem in for loop
by hdb (Monsignor) on May 16, 2013 at 08:48 UTC

So you want

```if (y-a)&&(z-c)< threshold
print as following
link1 x a  # not b as you stated above?

Then my next proposal is

```use strict;
use warnings;

my \$threshold = 1000;

# being lazy:
my @file_array = map { [ split /\s+/ ] } <DATA>;

for( my \$i=0; \$i<@file_array-2; \$i+=2 ) {
if( \$file_array[\$i  ][3]-\$file_array[\$i+2][2] < \$threshold and
\$file_array[\$i+1][3]-\$file_array[\$i+3][2] < \$threshold ) {
print "\$file_array[\$i  ][0] \$file_array[\$i  ][2] \$file_array[\$
+i+2][2]\n";
print "\$file_array[\$i+1][0] \$file_array[\$i+1][2] \$file_array[\$
+i+3][3]\n";
} else {
# not sure
print "\$file_array[\$i  ][0] \$file_array[\$i  ][2] \$file_array[\$
+i  ][3]\n";
print "\$file_array[\$i+1][0] \$file_array[\$i+1][2] \$file_array[\$
+i+1][3]\n";
}
}
print "\$file_array[-2][0] \$file_array[-2][2] \$file_array[-2][3]\n";
print "\$file_array[-1][0] \$file_array[-1][2] \$file_array[-1][3]\n";

__DATA__

However, this gives wrong results for link6 but I do not understand your example as the threshold condition seems not to be met??

Create A New User
Node Status?
node history
Node Type: note [id://1033788]
help
Chatterbox?
and the fog begins to lift...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2018-05-22 20:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
World peace can best be achieved by:

Results (165 votes). Check out past polls.

Notices?