Remember to add an "or die: $!" (or croak) after the open. That will write a useful message to the error log.
my $file = 'somedir/somefile.dat';
open FILE, "< $file" or die "Cannot open $file for reading: $!";
The problem is likely bad permissions. You run from the command line as a different set of permissions from the Web server. It's also possible that if you're running the file from a different location, your paths could be wrong and the system can't find the file specified.
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats. |