At 10:29 am -0500 13/11/03, Kev wrote:
 I have been beating my head on what should be a simple problem, appending a
 line to a .html file.

#!/usr/bin/perl

 use strict;
 use warnings;

 my $line_to_write="I've appended a line to a file !";
 my $file_name="/perl_work/test1.html";

open DAT,">>$file_name";

print DAT "$line_to_write\n";

close DAT;

 I get no errors but I do get a new file created with no .html extender just
 test1 rather than appending to test1.html. What beginner mistake am I
 making?


I can only think your path is invalid or you have a problem with permissions.

You should always do or die on opening a file handle. Try this:


#!/usr/bin/perl use strict; use warnings; chdir "$ENV{HOME}/desktop" ; my $s = "I've appended a line to a file !" ; my $f = "test1.html" ; open F, ">>$f" or die $! ; print F "<p>\n$s\n<\p>\n"; close F ; `open -a Safari $f` ;



JD




Reply via email to