in reply to Stringifying undefs
You could play tricks with tie -- I'm not advocating it, but it is a possibility depending upon your purpose.
{ package Undef; sub TIESCALAR{ bless \pop, 'Undef';} sub STORE{ $$_[0] = $_[1]; } sub FETCH{ defined $$_[0] ? $$_[0] : 0 } }; tie $x, 'Undef'; $x = 0; print "'$x'"; '0' $x = ''; print "'$x'"; '' $x = undef; print "'$x'"; '0'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Stringifying undefs
by ambrus (Abbot) on Mar 02, 2004 at 15:39 UTC |