Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Invalid use of constant pragma?

by mikeB (Friar)
on Nov 29, 2001 at 01:42 UTC ( [id://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.


      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?

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-04-14 19:39 GMT
Find Nodes?
    Voting Booth?

    No recent polls found