Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Private method variations

by adrianh (Chancellor)
on Mar 01, 2004 at 00:42 UTC ( #332744=perlmeditation: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    package Foo;
    
    ...
        # we can use lexically scoped subs
        $self->$_private();
    };
    
  2. or download this
    package Foo;
    
    ...
        my $self = shift;
        $self->Foo::private::method { ... };
    };
    
  3. or download this
    sub Foo::MY::method { ... };
    
    ...
        my $self = shift;
        $self->MY::method();
    };
    
  4. or download this
    package MY;
    
    ...
        my $method = caller() . "::$AUTOLOAD";
        $self->$method(@_);
    };
    
  5. or download this
    sub MY::method { ... };
    
  6. or download this
    sub MyLongPackageName::MY::method { ... };
    
  7. or download this
    package MY;
    use strict;
    ...
    FILTER_ONLY code => sub { s/(\w+::)*MY::/${Imported_from}::MY::/gs };
    
    1;
    
  8. or download this
    package Foo;
    use MY;
    ...
    sub MY::greet_world {
        print "A new Bar has entered the world\n";
    };
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (9)
As of 2015-07-08 05:37 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 (94 votes), past polls