Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Output to file question

by swkronenfeld (Hermit)
on Jul 21, 2004 at 23:35 UTC ( [id://376415]=note: print w/replies, xml ) Need Help??


in reply to Output to file question

I just want to mention, since it sounds like you are a beginner in Perl, that the method given by ysth will overwrite the contents of your file. If you want to append to a file, you need to open the file as

open my $handle, ">> filename" or die "Couldn't open file: $!";

Note the ">>" instead of ">".

You can print anything else to the file using

print $handle "Hello, world\n"; print $handle $some_other_var;

until the close command is executed on $handle.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (5)
As of 2024-03-28 13:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found