in reply to Add Contents At last in a File
If you don't want to open twice, once for writing and again for reading, use "+<" as the mode for the initial open like so:
my $file = "D:/swift/file.tmp"; open (FILE, "+< $file") || die "Couldn't open $file: $!"; print FILE "Add some text"; close (FILE);
By the way, you don't need to double up backslashes; you can use single forward slashes as path delimiters on Windows. Just one less thing to worry about. And checking to see if open calls were successful is a good idea.
Hope this helps.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Add Contents At last in a File
by AReed (Pilgrim) on Aug 09, 2005 at 13:34 UTC |