I've been having problems appending text to a file. I can't figure out
what is going on.

Here is a simple script that illustrates the problem. I have a file
named " extractedFiles". (The first character in its name is a space.)
It lives in the directory indicated in this script.

#!/usr/bin/perl -w

   my $headdir = "$ENV{HOME}/Perl/MyPerl/Virus/New Viruses/Headers";
   # my $headdir = "$ENV{HOME}/Desktop";

   open EXTRACTED, ">>$headdir/ extractedFiles"
           or die "cannot open extractedFiles: $!";
   print EXTRACTED "Extracting head from somefile\n";
   close EXTRACTED;

When I run the script, nothing is appended to " extractedFiles". The
content of the file is unchanged. But its "Date modified" time has changed
to the time when the script was run.

If I comment out the first "my $headdir" line and uncomment the second,
the script works just as it should. Every time it is run another line is
appended to the " extractedFiles" file on my desktop.

BTW, both " extractedFiles" files have the same permissions, "-rw-r--r--".

Any ideas would be greatly appreciated!

Regards,

Vic

--
Vic Norton
vic at norton dot name

Reply via email to