Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Invalid use of constant pragma?

by mikeB (Friar)
on Nov 29, 2001 at 01:42 UTC ( #128198=note: print w/replies, xml ) Need Help??


in reply to Invalid use of constant pragma?

ARGV elements are undef, not a null string, when not supplied. Try the following to see...
use Data::Dumper; # Because of my C++ background use constant PROJECT => $ARGV[0]; use constant ARCHIVE => $ARGV[1]; # debuggging print "PROJECT value = " . PROJECT . "\n"; print "ARCHIVE value = " . Dumper(ARCHIVE) . "\n"; if( ARCHIVE eq "") { warn( "No archive file was supplied.\n"); exit 1201; }

Replies are listed 'Best First'.
Re: Re: Invalid use of constant pragma?
by Fastolfe (Vicar) on Nov 29, 2001 at 09:22 UTC
    The fact that $ARGV[1] (thus ARCHIVE) is undef and not an empty string isn't really relevent. He's doing a test for string equality via eq, and undef stringifies to an empty string, so the test should succeed.
    $ perl -e 'print "OK\n" if undef eq ""' OK
      D'Oh! You are, of course, correct :/

      I'll just pass along tye's CB suggestion that perhaps use strict; would be in order, to verify no typos exist in the actual code.

      Mike

      use strict; - don't leave home without it

Re: Re: Invalid use of constant pragma?
by dhable (Monk) on Nov 29, 2001 at 02:28 UTC
    I did try the Data::Dumper package and I got the following output:
    ARCHIVE value = $VAR1 = '';
    Does this mean that the variable is set? I thought that's what I read about Data::Dumper.
      Interesting. When I run the program as in my previous node it displays ARCHIVE value = $VAR1 = undef; This is with Perl 5.6.0, ActiveState build#623.
        ActiveState v5.6.1 build 629

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://128198]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2022-01-19 09:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (55 votes). Check out past polls.

    Notices?