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.