Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Private Class Methods

by japhy (Canon)
on Apr 05, 2002 at 19:12 UTC ( #157029=note: print w/replies, xml ) Need Help??


in reply to Private Class Methods

By "private" do you mean it can be only called from inside your actual module? If so, then you could do something like this. You can get around it, but it requires a bit of effort (and the know-how). Here's a function to turn any method into a private method.
sub privacy { my $owner = __PACKAGE__; my ($pkg, $file, $func) = (caller 1)[0,1,3]; unless ($pkg eq $owner and $file eq __FILE__) { require Carp; Carp::croak("'$func' is a private method of $owner"); } }

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a (from-home) job
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://157029]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2022-08-18 14:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?