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

Re: Using can With Inheritance

by JadeNB (Chaplain)
on Jul 22, 2008 at 23:19 UTC ( #699452=note: print w/replies, xml ) Need Help??


in reply to Using can With Inheritance

I think that you are manually implementing inheritance. The following code:
use strict; use warnings 'all'; package A; sub _write_file { print "Writing in package A\n"; } sub write_file { my $self = shift; $self->_write_file(@_); } package A::B; use base qw/A/; sub new { my $class = shift; bless {} => $class; } sub _write_file { print "Writing in package A::B\n"; } my $writer = A::B->new; $writer->write_file;
prints "Writing in package A::B" (followed by a newline, of course!), which seems to be what you want. The point is that, even though write_file is a method in package A, it's calling _write_file on an object blessed into package A::B. Am I misunderstanding what you're trying to do?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://699452]
help
Chatterbox?
[shmem]: maybe that supports ctags, check the documentation
[Lady_Aleena]: I'd have to talk to a geany person to see.
[Lady_Aleena]: Right now, I'm trying to decide whether I want to rewrite how variables are entered in the sub I'm working on.
[shmem]: wait, what? you want that person to read the documentation for you?
[Lady_Aleena]: I might have to go with options instead of a straight list.
[Discipulus]: if more than 3 go for named variables LA
[Lady_Aleena]: Discipulus, it is at 2 now, but with what I am thinking about, it could go to 3. However, only 1 is needed. The second and third are optional.
[shmem]: straight list or named parameters - that depends on whether (and how many) optional arguments you have
[Discipulus]: if so a plain list is ok, imho
[Lady_Aleena]: shmem, I already have the plugin installed, just not active.

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











    Results (506 votes). Check out past polls.