by krahnj@[EMAIL PROTECTED]
(John W. Krahn)
May 12, 2008 at 11:31 AM
Tatiana Lloret Iglesias wrote:
> Hi all!
Hello,
> i'm running the following dummy program which just opens a file and I
get an
> error (die message)
>
> #!/usr/bin/perl
>
>
> if ( @[EMAIL PROTECTED]
eq '' )
@[EMAIL PROTECTED]
is an array slice (a list) and it makes no sense to compare a
list to a string. It looks like you want something like this:
if ( @[EMAIL PROTECTED]
!= 1 ) # must have 1 argument
Where you compare an array in scalar context which returns the number of
elements in that array.
> {
> 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
Is the file in the current directory? Does the file name contain spaces
or any other odd characters?
> any idea?
If you just want to test that the file is readable you can use the -r/-R
file test:
-r $ARGV[0] or warn "$ARGV[0] is not readable by this user";
perldoc -f -X
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall