Problem solved. There was something wrong with the file. It was encoded in Unicode(UTF-16), whatever that means. I have no idea how it got that way. Apparently my script was just adding invisible lines to the file.

(The Encoding option is at the bottom of the File Options icon in the BBEdit Status Bar.)

Solution. I just copied what I needed to a new " extractedFiles" (encoded in Mac Roman). Now I have no problems appending lines.

Regards,

Vic

At 6:25 PM -0400 10/22/03, Vic Norton wrote:
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