in reply to Append to text file not working
The problem is elsewhere. The three variations you found on PM work.
>type foo.pl my $logfile = 'foo.log'; open(my $log_fh, ">>", $logfile) or die "Can't open logfile: $!\n"; print $log_fh scalar(localtime), "\n"; >type foo.log The system cannot find the file specified. >perl foo.pl >type foo.log Thu Feb 21 17:59:01 2008 >perl foo.pl >type foo.log Thu Feb 21 17:59:01 2008 Thu Feb 21 17:59:05 2008
Note: I used a lexical ($log_fh), but using a package variable (LOG1) works too.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Append to text file not working
by ikegami (Patriarch) on Feb 21, 2008 at 23:02 UTC | |
by tilly (Archbishop) on Feb 21, 2008 at 23:21 UTC | |
by cmeyer (Pilgrim) on Feb 22, 2008 at 02:19 UTC | |
by tilly (Archbishop) on Feb 22, 2008 at 03:06 UTC |