From: [email protected]
[mailto:[email protected]] On Behalf Of SAQIB
RAFIQUE
Sent: 03 July 2009 07:27
To: [email protected]
Subject: PERL create file

> Hi,
> Can any body tell me what is wrong with my code below, I am trying to
create a file before writing/appending 
> data in it? Code line to create and open it as below:
> 
> $output = "/home/saqib/performance_debug_20090703.txt";
> open(OUTPUT,"+>>$output") || die("Could not open output file ! \n");

Its not exactly clear what you are trying to do, as your code doesn't
quite match you description (you don't mention wanting to read from the
file as well). Also, you don't say what problems you are having. To
improve your I would advise using the 3 argument form of open, localise
the file handle, and include the reason for the failure in your error
message. 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";

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.

HTH

-- 
Brian Raven 
This e-mail may contain confidential and/or privileged information. If you are 
not the intended recipient or have received this e-mail in error, please advise 
the sender immediately by reply e-mail and delete this message and any 
attachments without retaining a copy.

Any unauthorised copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to