Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Appending Files

by Lhamo_rin (Friar)
on Jul 21, 2003 at 16:00 UTC ( [id://276328]=perlquestion: print w/replies, xml ) Need Help??

Lhamo_rin has asked for the wisdom of the Perl Monks concerning the following question:

Fellow Monks,
Is there a perl command that will allow me to save several variables to the end of a file rather than overwrite the file?
Llamo_rin

Replies are listed 'Best First'.
(jeffa) Re: Appending Files
by jeffa (Bishop) on Jul 21, 2003 at 16:04 UTC
    Sure, just open the file in append mode:
    open FH, '>>', 'foo.txt' or die "can't append: $!"; print FH, $stuff; close FH;

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
Re: Appending Files
by belg4mit (Prior) on Jul 21, 2003 at 16:01 UTC
    open, The Friendly Manual is your friend.

    --
    I'm not belgian but I play one on TV.

Re: Appending Files
by Mr. Muskrat (Canon) on Jul 21, 2003 at 16:05 UTC
    Read all about open in perlfunc. Pay particular attention when you get to the part about MODEs.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-19 23:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found