Someone can probably give a better answer, but practically speaking, this is what I've
seen to be true (someone please give me a verbal whipping if I'm off here):
Perl evaluates a statement as false if it
a) is undefined
b) evaluates to 0
c) evaluates to '' (empty string)
and evaluates to true if it is not false.
"$state = ()" assigns the value of an empty list to the scalar $state, so it would
evaluate to false.
"$state = []", however, assigns a reference to an anonymous array to $state. It looks
something like this: ARRAY 0x9999999 (I don't know how many digits).
This is not case a,b,or c above, so it is true, even though the dereferenced array
itself (@{$state}) may be empty, and evaluate to false.
As for the way the reference docs are set up, I agree with you that they are not very
intuitive. I personally recommend installing ActivePerl on a computer somewhere so
that you have the benefit of all of the documentation converted to HTML in a much more
intuitive format.
-----Original Message-----
From: Harald Richard Ashburner [mailto:[EMAIL PROTECTED]
Sent: Thu 7/15/2004 10:21 PM
To: Tim Johnson
Cc: David Arnold; [EMAIL PROTECTED]
Subject: Re: !$state
<snip>
so to investigate this further, I want to look at what perl takes as
"Truth". I want to nail down for my own benefit the differences between
uninitialized, undef, initialized as a reference to an empty hash or
array or whatever. How these compare with the return value of undef()
etc.
Quick, to the Fine Manual!
perldoc perldoc tells me all about formatting and gives me the actually
useful switches for the purposes of finding documentation:
-f if I want documentation on a function
-q to 'grep' the perl faqs
Question:
How do I get an index or a table of contents? How do I find out how to search
the perldocs for
"control structures"
<snip>