Re: Perl script does not work
- From: "A. Sinan Unur" <1usa@xxxxxxxxxxxxxxxxxxx>
- Date: Sat, 29 Apr 2006 20:10:26 GMT
"CSUIDL PROGRAMMEr" <syedamjad_a@xxxxxxxxx> wrote in
news:1146333247.131872.286590@xxxxxxxxxxxxxxxxxxxxxxxxxxxx:
foreach my $file ( @files ) {
FILES: foreach my $file ( @files ) {
open(OLD, "<$file") or push @errors, "failed to open $file: $!";
It is good that you check for errors, but
* Further down, you still attempt to read from this file. You should
stop processing this file if you cannot open it
* Use lexical filehandles.
* perldoc -q vars
* You don't need the paratheses in the open call as you are using the
lower precedence or rather than ||.
* Use the three argument form of open.
unless ( open my $old, '<', $file ) {
push @errors, "Failed to open '$file': $!";
next FILES;
}
open(TEMP, ">temp.txt") or push @errors, "failed to create temp
file: $!";
Ditto.
These are in addition to comments by others.
Sinan
--
A. Sinan Unur <1usa@xxxxxxxxxxxxxxxxxxx>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
.
- Follow-Ups:
- Re: Perl script does not work
- From: John Bokma
- Re: Perl script does not work
- References:
- Perl script does not work
- From: CSUIDL PROGRAMMEr
- Perl script does not work
- Prev by Date: FAQ 6.3 How can I pull out lines between two patterns that are themselves on different lines?
- Next by Date: Re: share a session between two website
- Previous by thread: Re: Perl script does not work
- Next by thread: Re: Perl script does not work
- Index(es):
Relevant Pages
|