Re: PERL create file
by Bill Luebkert other posts by this author
Jul 3 2009 4:27AM messages near this date
RE: PERL create file
|
Re: PERL create file
Brian Raven wrote:
>
> To
> improve your I would advise using the 3 argument form of open, localise
> the file handle,
Neither of those suggestions 'should' change a thing.
and include the reason for the failure in your error
> message.
That's what would be useful, change the or die to :
open OUT, "+> >$output" or die "open for read/append $output: $! ($^E)";
or (if read not needed):
open OUT, "> >$output" or die "open for append $output: $! ($^E)";
and maybe you'll get something useful (assuming it's dieing on the open).
The $^E should give additional helpful text since $! is often cryptic.
> So, to open a file for appending, creating it if it doesn't
> exist, I might have the following.
>
> my $output = "/home/saqib/performance_debug_20090703.txt";
> open my $fd, ">>", $output or die "Failed to open $output: $!\n";
I'm guessing he may want to read as well as write or he doesn't
understand what +> > means. There's nothing wrong with the code
per se - the only probable error might be one of permissions on
the output dir, but seeing as it's apparently to his home dir,
theat would seem unlikely unless it's like in a CGI script running
as a different user or some such.
> As it is an output file you should also check that the close was
> successful, as this is where any disk dull errors will, usually, be
> discovered.
_______________________________________________
ActivePerl mailing list
ActivePerl@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Saqib Rafique
Brian Raven
Bill Luebkert
Ingo Schwarze
Bill Luebkert
Serguei Trouchelle
Bill Luebkert
Jan Dubois
Ingo Schwarze
Mohammed Mustafa
Stanislaw Romanski
|