develooper Front page | perl.perl5.porters | Postings from May 2004

Re: undef loses it magicness when assigned to a variable?

Thread Previous | Thread Next
Stas Bekman
May 27, 2004 00:55
Re: undef loses it magicness when assigned to a variable?
Message ID:
Why the ideas always come a second after hitting the send button. The obvious 
thing I was missing is to check how pp_defined does the thing. I shouldn't 
have been wasting time searching in the docs :)

Stas Bekman wrote:
> So how do I check in C whether the passed variable (or a random sv) is 
> undef or not if comparing to &PL_sv_undef doesn't work? 

So I've changed:

- ST(0) == &PL_sv_undef
+ (!ST(1) || !SvANY(ST(1))

and voila, it works whether I call:



   $x = undef;

> am I missing 
> some obvious RTFM section? I've read: 'perlguts:=head2 AVs, HVs and 
> undefined values'
> but it doesn't seem to be related. There were many other references to 
> undef in the perl manpages, but I didn't find anything useful.

This should probably be added to the perlguts manpage, next to the
'=head2 AVs, HVs and  undefined values' item.

=head How to check arguments for undefine-ness

Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker     mod_perl Guide --->

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About