ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> activeperl
activeperl
RE: PERL create file
by Brian Raven other posts by this author
Jul 3 2009 4:08AM messages near this date
PERL create file | Re: PERL create file
From: activeperl-bounces@[...].com
[mailto:activeperl-bounces@[...].com] On Behalf Of SAQIB
RAFIQUE
Sent: 03 July 2009 07:27
To: activeperl@[...].com
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 inten
ded 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 stric
tly forbidden.

_______________________________________________
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

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved