Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

When numeric conversion overloading goes awry.

by dmitri (Curate)
on Jan 24, 2006 at 19:21 UTC ( #525293=perlquestion: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use overload ("0+" => 'value');
    sub value {
        my $self = shift;
        exists $self->{'-value'} ? $self->{'-value'} : undef;
    }
    
  2. or download this
    sub gen_id { sprintf "%U", $_[1] }
    
  3. or download this
    package My;
    
    ...
    package main;
    my $var = My->new;
    print int($var);
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://525293]
Approved by Corion
Front-paged by bart
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2014-12-27 10:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (176 votes), past polls