I've got one question about scalar polymorphism:
How do I do to set up a scalar value eg '$foo' which has a numeric value in a numeric context and has a string value in a string context ?
For instance, I'd like to do something like that:
my $err = ???? ; my $num = $err + 0 ; print $num ; # Will print lets say the number '1' ; print $err ; # Will print the string 'ERROR 1' ;
I saw this type of behaviour in BerkeleyDB module and I wonder how it works.
Thanks for your precious help.
-- Nice photos of naked perl sources here !
You probably want dualvar from Scalar::Util
/J\
Use "dualvar" from Scalar::Util.
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
++
Absolutely. I'm not a fan of doing funky things that you can't immediately see in code. It's a maintenance headache. Sometimes it's fun to do, but if you can avoid it, that's a good thing. It's one of the reasons I rarely use tied variables.
Cheers,
Ovid
New address of my CGI Course.
perlmonks.org content © perlmonks.org and davorg, gellyfish, jeteve, Ovid, perrin
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03