Re: Perl Syntax

From: Matthew Seaman (m.seaman_at_infracaninophile.co.uk)
Date: 06/30/04

  • Next message: Skylar Thompson: "Re: OT: Cable management"
    Date: Wed, 30 Jun 2004 18:34:59 +0100
    To: Drew Tomlinson <drew@mykitchentable.net>
    
    
    

    On Wed, Jun 30, 2004 at 10:17:45AM -0700, Drew Tomlinson wrote:
    > On 6/30/2004 10:04 AM Steve Bertrand wrote:

    > >I know this works:
    > >
    > >if ($ARGV[0] eq '') {
    > > print "Debug Mode\n";
    > >}

    > 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.

    Unless you supply at least one argument to the script, $ARGV[0] won't
    exist. There's a difference in perl between 'not defined' and an
    empty string (or zero for numerical values). Try:

        if ( @ARGV < 1 ) {
            usage();
            exit 1;
        }

    or

        unless ( defined $ARGV[0] ) {
            usage();
            exit 1;
        }

    -- 
    Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                          Savill Way
    PGP: http://www.infracaninophile.co.uk/pgpkey         Marlow
    Tel: +44 1628 476614                                  Bucks., SL7 1TH UK
    
    



  • Next message: Skylar Thompson: "Re: OT: Cable management"

    Relevant Pages

    • Re: AIX 5.3 disaster recovery fro AIX newbie
      ... >are you in the server in maint mode? ... I know just because I cannot get in and examined the script it ran. ... one of the scripts smoked /etc/passwd file, to zero. ... If you are not the intended recipient ...
      (AIX-L)
    • Re: Why must I chomp a variable set in a script?
      ... If they are of zero size, ... it is supposed to trigger the email program to notify the users. ... have to "chomp" the variable to get this to work? ... like the value was supplied from the command line, it is set in the script. ...
      (perl.beginners)
    • Re: problem with a file processing script
      ... but I am far from a script writer, and I recently run into a little ... if the file I am looking for is zero ... the $NEWNUM it's because the extension the third party software is ... print that $EQFILE existed but was empty ...
      (comp.unix.shell)
    • Re: problem with a file processing script
      ... but I am far from a script writer, and I recently run into a little ... if the file I am looking for is zero ... the $NEWNUM it's because the extension the third party software is ... print that $EQFILE existed but was empty ...
      (comp.unix.shell)
    • Re: converting file to excel problem
      ... Shawn wrote: ... > We are using the below script to convert a file into excel format. ... > problem is that my file contains ssn in which they can start with zero. ...
      (comp.lang.perl.misc)