Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^4: Use cases for 'sub Pckg::func { }' ?

by LanX (Saint)
on Aug 03, 2020 at 13:54 UTC ( [id://11120256]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Use cases for 'sub Pckg::func { }' ?
in thread Use cases for 'sub Pckg::func { }' ?

Thanks.

I can see two/three use patters now

  • your demo: ad hoc definition of small but related OOP classes in a horizontal way (contrary to "vertical" inheritance)
  • keeping the class' namespace clean of imported subs (kind of namespace::clean but right from the beginning)
the latter even
  • on a method basis
  • without need of explicit import
{ package Subs::I::Want; sub Target::Class::method { my ($self) = shift; $self->method2(); sub_I_want() } } { package Other::Subs::I::Want; sub Target::Class::method2 { other_sub_I_want() } }

hence

  • Target::Class->method() or ->method2() work
  • Target::Class->sub_i_want() or ->other_sub_I_want() won't work
GREAT, learned something new! :)

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-19 03:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found