in reply to Array question
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Array question
by AnomalousMonk (Archbishop) on Nov 20, 2009 at 18:24 UTC | |
|
Re^2: Array question
by Karger78 (Beadle) on Nov 20, 2009 at 17:27 UTC |