Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Output to file question

by swkronenfeld (Hermit)
on Jul 21, 2004 at 23:35 UTC ( #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? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2022-12-09 23:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?