On May 12, 2008, at 09:05, Tatiana Lloret Iglesias wrote:
Hi all!
i'm running the following dummy program which just opens a file and
I get an
error (die message)
#!/usr/bin/perl
if ( @ARGV[0] eq '' )
{
print "\nUSAGE:\n\t genenames.pl genes.txt \n\n";
exit;
}
my $file = $ARGV[0];
open(FICH,"$file") or die "cannot open $file";
I've tried to pass the input parameter ARGV[0] with / with \ with
relative
path ... but nothing
any idea?
Thanks a lot!
T
Your code looks like it should work, so the only thing you can do is
get perl to tell you why it can't open the file. The $! variable
contains the error number/message (depending on context) for system
calls, so you can say
open my $fh, "<", $file
or die "could not open $file: $!";
Note the usage of the three argument version of open. It is safer
than using the two argument version. Also note the usage of lexical
file handles. The only bareword filehandles you should be using are
STDIN, STDOUT, STDERR, and DATA.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/