Date: Wed, 30 Jun 2004 12:49:22 -0500 From: Josh Paetzel <friar_josh@tcbug.org> To: Drew Tomlinson <drew@mykitchentable.net> Cc: Steve Bertrand <steveb@eagle.ca> Subject: Re: Perl Syntax Message-ID: <20040630174921.GA11187@ns1.tcbug.org> In-Reply-To: <40E2F5B9.305@mykitchentable.net> References: <40E2EF7E.3000901@mykitchentable.net> <4769.209.167.16.15.1088615085.squirrel@209.167.16.15> <40E2F5B9.305@mykitchentable.net>
next in thread | previous in thread | raw e-mail | index | archive | help
> >>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 for your reply. I tried your suggestion and it seems to work but > I get this output: > > Use of uninitialized value in string eq at ./test.pl line 16. > You must include the file name. > > I have "use warnings;" and "use strict;" in the script. I assume the > error comes from the "use warnings;" but why does perl see "eq" as a > string and not an operator? Or am I misinterpreting the message? > > Thanks, > > Drew > #!/usr/bin/perl -w if (!ARGV[0]) { print "no arguements\n"; } else { print "found an arguement\n"; } Josh Paetzel
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040630174921.GA11187>