Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: 20 most important Perl Best Practices

by tobyink (Abbot)
on Aug 24, 2012 at 15:56 UTC ( #989577=note: print w/replies, xml ) Need Help??


in reply to 20 most important Perl Best Practices

"In Perl it is not possible to create a private function like in Java or C++."

It's not especially difficult...

sub my_function { croak "my_function is private" unless caller(0) eq __PACKAGE__; # body of function goes here }

MooseX::Privacy makes creating private and protected methods really easy (if you're already using Moose).

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Replies are listed 'Best First'.
Re^2: 20 most important Perl Best Practices
by greengaroo (Hermit) on Aug 29, 2012 at 13:13 UTC

    Interesting! I didn't know about MooseX-Privacy! Thanks!

    There are no stupid questions, but there are a lot of inquisitive idiots.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://989577]
help
Chatterbox?
[Eily]: I just wrote a oneliner to solve a (non perl) colleague's problem, and it worked on the first try
[Eily]: and he wasn't impressed
1nickt adds gingersnaps to the platter on the sideboard.
[Eily]: sure it was a pretty standard one liner (of the $h{$1} = $2 if /regex/; END { pp \%h; } variety), but he's not supposed to know that!

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (10)
As of 2017-04-26 15:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (482 votes). Check out past polls.