Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to save a file

Status
Not open for further replies.

cnw40007

Technical User
Mar 4, 2003
35
IE
Hi, Can anybody give me some sample code on how you would go about saving a text file into a folder??
 
[tt]sub save {
my( $filename, $foldername, $filecontents ) = @_;
open( FILE, ">$foldername/$filename" )
or die "$0: can't open $foldername/$filename: $!";
print FILE $filecontents
or die "$0: can't write $foldername/$filename: $!";
close( FILE )
or die "$0: can't close $foldername/$filename: $!";
}[/tt]
"As soon as we started programming, we found to our surprise that it wasn't as
easy to get programs right as we had thought. Debugging had to be discovered.
I can remember the exact instant when I realized that a large part of my life
from then on was going to be spent in finding mistakes in my own programs."
--Maurice Wilk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top