in reply to Undefined Hash Values and Ternary Operators

I used the following script with no problems.
#!/usr/bin/perl $x='y'; # comment this line out to test undef case. %p = ( 'a' => 'B', 'z' => defined($x) ? $x : 'n', 'c' => 'D'); print $p{z}
(BTW:When you call warn it will generate a warning with the input you give it, so I'm not surprised by the warning you got. If you intended it as a test clause then you should say warn 'err' if( !defined($x) ); or something like that.)
Oh, and yes... if you include an undef in an array it will get dropped, which is why your hash was acting funny.

Replies are listed 'Best First'.
RE: Re: Undefined Hash Values and Ternary Operators
by merlyn (Sage) on May 25, 2000 at 21:13 UTC
    It has been said:
    Oh, and yes... if you include an undef in an array it will get dropped, which is why your hash was acting funny.
    This is not true. undef is a valid element of a list, and therefore an array.