Perl Syntax

Steve Bertrand steveb at eagle.ca
Wed Jun 30 10:04:37 PDT 2004


> I'm using perl 5.8.4 on a 4.9 machine.  I want to add code a perl script
> to check for value passed from command line.  If it is null, I want to
> exit with an error message.
>
> First I tried this and got "Use of uninitialized value in string eq at
> ./test.pl line 20."
>
> if ($ARGV[0] eq "") {
>   print "You must include the file name.";
>   exit 1;
> }
>
> Next I tried this but get "Use of uninitialized value in length at
> ./test.pl line 20."
>
> if (length ($ARGV[0]) = "0") {
>   print "You must include the file name.";
>   exit 1;
> }
>
> I've searched the web and all examples that I've found indicate that I'm
> doing things correctly but obviously I'm not.  What am I doing wrong?
>

I know this works:

if ($ARGV[0] eq '') {
        print "Debug Mode\n";
}

Cheers,

Steve

> Thanks,
>
> Drew
>
> --
> Visit The Alchemist's Warehouse
> Magic Tricks, DVDs, Videos, Books, & More!
>
> http://www.alchemistswarehouse.com
>
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to
> "freebsd-questions-unsubscribe at freebsd.org"
>




More information about the freebsd-questions mailing list