Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: overwrite a file

by punch_card_don (Curate)
on Apr 01, 2005 at 22:59 UTC ( [id://444315]=note: print w/replies, xml ) Need Help??


in reply to overwrite a file

Do you mean you're trying to create a "copy" subroutine to use in a program? Something like:
sub copy( source, destination ) { open SOURCEFILE "source"; open DESTINATIONFILE "destination"; while (<SOURCEFILE>) { print DESTINATIONFILE ; } close DESTINATIONFILE; close SOURCEFILE; }

If so, then maybe the problem is in how you're opening the destination file.

open FILE "<$file";
to read a file
open FILE ">$file";
to write to a file, creating it if necessary
open FILE ">>$file";
to append to a file, creating it if necessary

Forget that fear of gravity,
Get a little savagery in your life.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-25 20:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found