First, check that you're using
strict and
-w. I think you're getting errors that you can't see. In that case, check your log file.
Second, the way this operates depends a lot on how you're calling it. If you're opening a pipe, it could break, and then things could fall apart.
I have a sneaking suspicion, though, that you're doing something like this:
my $file = "foo.txt";
my $data;
read($file, $data, 1024);
Note that
read operates on a
file-handle, not a
file name. These need to be
opened:
my $file = "foo.txt";
open ($fh, $file) || die "Could not open file $file\n";
my $data;
read($fh, $data, 1024);
If you're feeling more progressive, you might try and use
IO::Handle instead of the
read anachronism.