http://qs1969.pair.com?node_id=92346


in reply to How to make bi-modal variables like $! ?

You'll need to do some overloading.
package DualVar; use overload ( '""' => sub { $_[0][0] }, '0+' => sub { $_[0][1] }, fallback => 1, ); sub new { bless [ @_[1,2] ], $_[0] } 1;
And that's all!
use DualVar; my $x = DualVar->new("japhy", 19); printf "I'm %s, and I'm %d years old.\n", $x, $x;


japhy -- Perl and Regex Hacker