On Sun, Mar 28, 2004 at 09:41:09AM -0500, Randy W. Sims wrote: > On 3/27/2004 9:15 PM, R. Joseph Newton wrote: > > >What is intriguing to me in this is that an overloaded operator > >wouuld be attched to a variable. this sounds like it gets into > >prtions of Perl that I've never really delved into. Is $! actually > >sored as a number? > > As John pointed out, it is stored as both a number and a string. Here is > a small example of how you can do something similar in your own code. > See 'perldoc overload' for more info. > > #!/usr/bin/perl > > package NumStr;
[ snip ] > my $ns = NumStr->new(42, 'The Answer to Life, the Universe, and Everything'); > printf("as number = '%d', as string = '%s'\n", $ns, $ns); use Scalar::Util "dualvar"; my $ns = dualvar 42, 'The Answer to Life, the Universe, and Everything'; printf("as number = '%d', as string = '%s'\n", $ns, $ns); > You can simulate more closely with XS: dualvar is XS. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>