$glob = "../dir/*.txt"; @listoitems = glob( $glob ); print br, 'Found: ', $#listoitems + 1, ' items', br; $i=0; print ''; foreach $item (@listoitems) { $item = pop(@listoitems); $i++; if ($i>9){$i=0;} if ($i =~ /0|2|4|6|8/) { @file=get_data($item); ##process and read the file tab1($file[0], $file[1], $file[2], $file[3], $file[4]); } #end if even# else { @file=get_data($item); ##process and read the file tab2($file[0], $file[1], $file[2], $file[3], $file[4]); } #end if odd# } #end foreach#