Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: if statement/uninitialized value

by malaga (Pilgrim)
on May 28, 2002 at 14:09 UTC ( #169772=note: print w/replies, xml ) Need Help??


in reply to if statement/uninitialized value

This place is so cool. I love it. Thanks for the answers.

I'm getting the unitialized error on whichever variable is uninitialized (depending on what I'm sending through the script). but my question is why is it getting past the if -e $info? if the file it doesn't exist it shouldn't run the if statement, right? and if it doesn't run the if statement i shouldn't get the error. what am i missing?

Replies are listed 'Best First'.
Re: Re: if statement/uninitialized value
by chromatic (Archbishop) on May 28, 2002 at 14:36 UTC
    $info must be undef:
    $ perl -w use strict; print -e undef; Use of uninitialized value in -e at - line 2. Use of uninitialized value in print at - line 2.
Re: Re: if statement/uninitialized value
by broquaint (Abbot) on May 28, 2002 at 14:46 UTC
    The Use of uninitialized value message is only a warning[1] and since warnings are merely advisory your program shall continue on it's merry way.
    if the file doesn't exist it shouldn't run the if statement, right?
    Right. So the code to be executed if the given condition is true won't be executed because -e undef will always return false.
    if it doesn't run the if statement i shouldn't get the error
    But the condition still has to be tested, so $info still has to be evaluated and the warning will be raised if $info hasn't been initialised at that point.
    HTH

    _________
    broquaint

    [1] for more info on warnings in perl see the perllexwarn and perldiag manpages

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2020-10-21 13:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (217 votes). Check out past polls.

    Notices?