From owner-freebsd-questions@FreeBSD.ORG Wed Jun 30 17:18:11 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9D00416A4CE for ; Wed, 30 Jun 2004 17:18:11 +0000 (GMT) Received: from relay03.roc.ny.frontiernet.net (relay03.roc.ny.frontiernet.net [66.133.131.36]) by mx1.FreeBSD.org (Postfix) with ESMTP id 37E1643D2D for ; Wed, 30 Jun 2004 17:18:11 +0000 (GMT) (envelope-from drew@mykitchentable.net) Received: (qmail 26762 invoked from network); 30 Jun 2004 17:17:44 -0000 Received: from 67-51-112-35.dsl1.elk.ca.frontiernet.net (HELO blacklamb.mykitchentable.net) ([67.51.112.35]) (envelope-sender )SMTP for ; 30 Jun 2004 17:17:44 -0000 Received: from [165.107.42.177] (unknown [165.107.42.177]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by blacklamb.mykitchentable.net (Postfix) with ESMTP id E86FA3BF422; Wed, 30 Jun 2004 10:17:42 -0700 (PDT) Message-ID: <40E2F5B9.305@mykitchentable.net> Date: Wed, 30 Jun 2004 10:17:45 -0700 From: Drew Tomlinson User-Agent: Mozilla Thunderbird 0.6 (Windows/20040502) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Steve Bertrand References: <40E2EF7E.3000901@mykitchentable.net> <4769.209.167.16.15.1088615085.squirrel@209.167.16.15> In-Reply-To: <4769.209.167.16.15.1088615085.squirrel@209.167.16.15> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit cc: FreeBSD Questions Subject: Re: Perl Syntax X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Jun 2004 17:18:11 -0000 On 6/30/2004 10:04 AM Steve Bertrand wrote: >>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 -- Visit The Alchemist's Warehouse Magic Tricks, DVDs, Videos, Books, & More! http://www.alchemistswarehouse.com