You don't need multiple foreach loops and if you're going to pass a filehandle to a sub, you should probably use IO::File to do so.use IO::File; foreach my $content (@contents) { $logfile = $pth .'\\' . $content; my $fs = filestamp($logfile); if ($fs == $datestamp) { print "$logfile --> is current, processing\n"; my $fh = new IO::File "$logfile" || die "Error $logfile: $!\n"; processFile($fh); $fh->close; } elsif ($fs == ($datestamp -1)){ print "$logfile --> is one day old, processing\n"; my $fh = new IO::File "$logfile" || die "Error $logfile: $!\n"; processFile($fh); $fh->close; } else { print "$logfile is out of date range\n"; } }
In reply to Re: If logic fails foreach mistake
by Ineffectual
in thread If logic fails foreach mistake
by dbrock
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |