Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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 drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2015-07-07 00:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (85 votes), past polls