baxy77bax has asked for the wisdom of the Perl Monks concerning the following question:

UPDATE: THIS IS EMBARRASSING PLEASE DO NOT READ FURTHER ! hi,

Please could someone take look at the code(pseudo code) and tell me why is the for loop skipped??? I am a bit tired but i still should see a reason, however i am not seeing it.

my @a; while(<INA>){ chomp; /^([^\t]*)\t([^\t]*)\t([^\t]*)\t([^\t]*)\t([^\t]*)\t/; if($2 eq $c){ push(@a,[$3,($3 eq '+')?($4):($5)]); } } close INA; foreach (@a){ my $la = $_->[1]+$optTSS; my $lb = $_->[1]-$optTSS; print "$la,$lb\n"; # it prints $la,$lb here for(my $i =$la; $i <=$lb;$i++){ # loop is skipped no printing print "$la,$lb,$i"; }; print ">\n"; }
so $lb and $la are printed just before the for loop, but not within.

thnx

Replies are listed 'Best First'.
Re: for loop is skipped for not so obvious reason (false)
by Anonymous Monk on Feb 06, 2013 at 11:41 UTC

    so $lb and $la are printed just before the for loop, but not within.

    Seeing how $la and $lb variables, the reason the loop is skipped is because $i <= $lb evaluates to false

      $ perl -E " my($la,$lb)=@ARGV; for ( my$i= $la; $i < $lb; $i++){ say $ +i; } " $ perl -E " my($la,$lb)=@ARGV; for ( my$i= $la; $i < $lb; $i++){ say $ +i; } " 0 0 $ perl -E " my($la,$lb)=@ARGV; for ( my$i= $la; $i < $lb; $i++){ say $ +i; } " 1 0 $ perl -E " my($la,$lb)=@ARGV; for ( my$i= $la; $i < $lb; $i++){ say $ +i; } " 0 1 0
Re: for loop is skipped for not so obvious reason
by Anonymous Monk on Feb 06, 2013 at 14:16 UTC

    UPDATE: THIS IS EMBARRASSING PLEASE DO NOT READ FURTHER !

    Nazdravlje :)

    You've earned $break :)