While removing entries from an array like that is inadvisable, your code will not work as expected for two reasons:
The following should work as you expect:
foreach my $currentremotefilelist (@remoteFilelist) { my $arrayCounter = -1; foreach my $currentlocalfilelist (@return2) { $arrayCounter++; # Increment on every loop iteration next if !defined $currentlocalfilelist; # Skip previousl +y deleted entries #myfile.txt =~ myfile.txt_date my $currentremotefilelistsize = -s $currentremotefilelist; my $currentlocalfilelistsize = -s $logSite.$currentlocalfileli +st; $currentlocalfilelist = $logSite.$currentlocalfilelist; if (($currentremotefilelist =~ /^$currentlocalfilelist/i) && ( +$currentremotefilelistsize == $currentlocalfilelistsize)) { print "$currentremotefilelist and $currentlocalfilelist al +so $currentlocalfilelistsize and $currentlocalfilelistsize They are E +qual and will not be copied\n\n"; delete $return2[$arrayCounter]; } else { print "$currentremotefilelist and $currentlocalfilelis +t also $currentlocalfilelistsize and $currentlocalfilelistsize are no +t EQUAL!!\n"; } } }
Updated: moved counter to above the next
In reply to Re: Array question
by gmargo
in thread Array question
by Karger78
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |