The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 03-18-2008
KevinADC KevinADC is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2008
Posts: 731
The biggest problem is that redo is outside a loop. There is nothing to redo. Maybe this is what you mean to do (with print commands added for tracking process) :


Code:
my @n = (10..100);
my $i;
my $j;

LINE1: for ($i; $i < 10; $i++) {
   $i = $n[int rand @n];
   $j += $i;
   if ( ((5500 - $j) < 10) || ((5500 - $j) > 100) ) {
      print qq{Inside "if" condition $j\n};
      redo LINE1; 
   }
   print $j,"\n"; 
}

Next time do as "era" has asked and elaborate a bit more. It's too hard to guess at your intentions or what your code should do.