title: Alternate looping nested foreach loops
body: <p>I am trying to print a value from one foreach loop. Then go to the other foreach loop and continue until the last elements in both arrays.</p>
  
  <pre><code>@list = (10, 20, 30, 40, 50);
  @list1 = (15, 25, 35, 45, 55);
  OUTER:foreach $a (@list) {
          print "value of a: $a\n";
          foreach $b (@list1) {
            print "value of b: $b\n";
            next  OUTER;
          }
        }
  </code></pre>
  
  <p>This returns the same value from the second foreach loop.</p>
  
  <pre><code>value of a: 10
  value of b: 15
  value of a: 20
  value of b: 15
  value of a: 30
  value of b: 15
  value of a: 40
  value of b: 15
  value of a: 50
  value of b: 15
  </code></pre>
  
  <p>The desired output should be as follows:</p>
  
  <pre><code>value of a: 10
  value of b: 15
  value of a: 20
  value of b: 25
  value of a: 30
  value of b: 35
  value of a: 40
  value of b: 45
  value of a: 50
  value of b: 55
  </code></pre>
  
  <p>Is there a way I can print values from both arrays alternately?? Any loop control statements can do this?</p>
  
  <p>I am just testing this logic because I am going to use it in a script of mine. Where, I will be opening a pair of files from the foreach loops and process it (one file per loop). The files I will be opening using foreach loops are in separate directories and are in a pool of several similar files. I will be looping in my code to open all of them using the nested foreach logic.</p>
  
  <p>The script would look something like this:</p>
  
  <pre><code>$dir1 = "/tmp/*";
  $dir2 = "/home/*";
  @files1 = glob( $dir1 );
  @files2 = glob( $dir2 );
  foreach (@files1) {
   .
   .
   . 
     foreach (@files2){
      .
      .
      .
     }
  }
  </code></pre>