Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Re: Use of uninitialized value errors

by dvergin (Monsignor)
on May 17, 2002 at 00:04 UTC ( [id://167145]=note: print w/replies, xml ) Need Help??


in reply to Re: Use of uninitialized value errors
in thread Use of uninitialized value errors

"This is happening because wherever you have a conditional based on a variable that may not contain a value"

Nope. Perl forgives you if you simply test or assign a bare uninitialized variable in a conditional. Your code works for this reason -- no warning for "if ($var)". Going over your post, I think this is a case where you understand but just mis-stated your assertion.

Note:

#!/usr/bin/perl -w use strict; my $stuff; # No complaint here if ($stuff) { print "hello\n"; } # No complaint here if (my $stuff2 = $stuff) { print "hello\n"; } # But this interpolation causes a warning if (my $stuff3 = "$stuff") { print "hello\n"; } # This concatenation complains also if (my $newstuff = "new $stuff") { print "hello\n"; }

------------------------------------------------------------
"Perl is a mess and that's good because the
problem space is also a mess.
" - Larry Wall

Replies are listed 'Best First'.
Re: Re: Re: Use of uninitialized value errors
by blackjudas (Pilgrim) on May 17, 2002 at 17:36 UTC
    True dvergin I was simply saying that if you make any decisions based on what a variable contains, if that variable is undefined, then perl will complain. But thank you for bringing that up!

    BlackJudas

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-19 21:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found