Re: Perl Syntax

From: Drew Tomlinson (drew_at_mykitchentable.net)
Date: 06/30/04

  • Next message: Charles Swiger: "Re: Using syslog(3) after chroot-ing"
    Date: Wed, 30 Jun 2004 10:17:45 -0700
    To: Steve Bertrand <steveb@eagle.ca>
    
    

    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
    _______________________________________________
    freebsd-questions@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-questions
    To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"
    

  • Next message: Charles Swiger: "Re: Using syslog(3) after chroot-ing"

    Relevant Pages

    • Re: Ctrl F
      ... Is your 1281.50 a text string, ... This command works for about three attempts then I begin getting the ... I am getting an error message ... | However when I page through the data I find it in different cells. ...
      (microsoft.public.excel.worksheet.functions)
    • Re: Memo Update
      ... characters with a LENfunction in Excel so that I know how manu characters ... the string literal contains.' ... directly in the command window. ... succeeds (I get no error message, and upon a subsequent select statement ...
      (microsoft.public.fox.programmer.exchange)
    • Re: Problem to test if string is non zero
      ... The $cmd string does not contain CHECKEDOUT in this case but the ... That said, if you want to check the exit status of a command, you can do: ... echo "Command ran ok!" ...
      (comp.unix.shell)
    • Re: error with string (beginner)
      ... hence your error message. ... Also note that everything input on the command line is a string, ... Check out the Python Cookbook for lots of good examples: ...
      (comp.lang.python)
    • Re: bash/echo/sed/date question (?)
      ... executes a command and returns the command's exit status, ... The error message is written to standard error. ... In the working version I have used the plain "date" command, ...
      (comp.unix.shell)