Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: If logic fails foreach mistake

by Ineffectual (Scribe)
on Mar 14, 2003 at 00:57 UTC ( [id://242913]=note: print w/replies, xml ) Need Help??


in reply to If logic fails foreach mistake

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"; } }
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.

HTH
'Fect

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://242913]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-04-19 08:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found