[oak perl] The mysterious "undef"
zed.lopez at gmail.com
Fri Mar 18 09:47:46 PST 2005
One aspect of use warnings is that you get a "Use of uninitialized
value" warning if you try to use an undef value.
Perl will auto-convert undef to '' if you use it as a string, and you
won't hear about it if you don't have warnings on.
Always turn warnings on for non-trivial scripts. (There are reasons to
turn it off for selected code blocks, and super-experts like Damian
Conway often do a lot of stuff with it off... but until you're a
super-expert and you _know_ you have a very good reason for having it
off for a specific piece of code, leave it on.)
This isn't a pointless issue: you should and must understand Perl's
automatic conversions, or its DWIMmery won't do what you mean.
On Fri, 18 Mar 2005 11:10:22 -0500, Sandy Santra <santranyc at yahoo.com> wrote:
> I keep seeing "undef" mentioned in the llama book.
> I've tried to define a variable as not having a value, theoretically being
> "undef," but when I use the print command, I never see "undef" print to my
> screen; nothing prints at all.
> I wanted to learn the different between a zero value and undef because the
> llama book keeps saying there is one. Is this a pointless issue to pursue?
> Clarification greatly appreciated. Thanks.
> Oakland mailing list
> Oakland at pm.org
More information about the Oakland