rbi has asked for the wisdom of the Perl Monks concerning the following question:
The Word module is using the Languages modulethat provides the _translate() method. Languages is using some other methods that are private and used only there.directories structure: . |-- Word.pm |-- WordExposed | |-- Languages.pm | `-- LanguagesPrivate | |-- French.pm | `-- Italian.pm files: # foo.pl use strict; use warnings; use lib ('/path_to_Word_pm'); use Word; my $word = Word->new(); $word->set('apple','it'); # Word.pm package Word; use strict; use Class::Struct; use WordExposed::Languages; struct Word => { english => '$', language => '$', translation => '$', }; sub set { my $self = shift(); my $english = shift(); my $language = shift(); $self->english($english); $self->language($language); $self->_translate(); } 1;
I'd like to come up with using WordExposed::LanguagesPrivate::French; and WordExposed::LanguagesPrivate::Italian; only in Languages.pm, so that I can simply put use WordExposed::Languages; in Word.pm and bury everything within Languages.pm.# Languages.pm package WordExposed::Languages; our @ISA = qw(Exporter); our @EXPORT = qw( _translate ); our @EXPORT_OK = qw(); sub _translate { my $self = shift(); if ($self->language eq 'fr') { $self->_traduction(); } elsif ($self->language eq 'it') { $self->_traduzione(); } } 1; # French.pm package WordExposed::LanguagesPrivate::French; our @ISA = qw(Exporter); our @EXPORT = qw( _traducion ); our @EXPORT_OK = qw(); sub _traducion { my $self = shift(); } 1; # Italian.pm package WordExposed::LanguagesPrivate::Italian; our @ISA = qw(Exporter); our @EXPORT = qw( _traduzione ); our @EXPORT_OK = qw(); sub _traduzione { my $self = shift(); } 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do I bury some code ?
by Anno (Deacon) on Aug 31, 2007 at 13:25 UTC | |
by rbi (Monk) on Aug 31, 2007 at 14:04 UTC | |
by Anno (Deacon) on Aug 31, 2007 at 14:55 UTC | |
by rbi (Monk) on Aug 31, 2007 at 16:14 UTC | |
by Anno (Deacon) on Aug 31, 2007 at 16:30 UTC | |
|
Re: How do I bury some code ?
by hossman (Prior) on Sep 01, 2007 at 05:29 UTC | |
|
Re: How do I bury some code ?
by dsheroh (Monsignor) on Aug 31, 2007 at 15:09 UTC | |
by rbi (Monk) on Aug 31, 2007 at 16:22 UTC |