[Firenze-pm] ed adesso una domanda di perl: export
Valerio Crini
vcrini at gmail.com
Fri Apr 3 13:01:03 PDT 2009
Innanzi tutto grazie ad entrambi per la risposta celere ed esauriente,
Ho provato ad utilizzare la strada quella dell'utilizzo di Exporter::Simple,
Export::Lexical ma entrambi non mi funzionano e non capisco perchè. Vi
porto alcuni esempi:
dato il package
Dnd::Utils::Codes
così fatto
#!/usr/bin/perl
package Dnd::Utils::Codes;
use strict;
use warnings;
use base 'Exporter::Simple';
use version;
our $VERSION = qv('0.1');
sub W_USAGE : Exported(codes) {
return 'usage';
}
1;
e utilizzandolo in
#!/usr/bin/perl
use strict;
use warnings;
use Dnd::Utils::Codes;
print W_USAGE();
mi funziona
ovvero mi stampa un favoloso
'usage'
MA
se lo lancio in un file fatto così
#!/usr/bin/perl
use strict;
use warnings;
use Dnd::Fourth::Power;
my $power = Dnd::Fourth::Power->new();
$power->print;
che a sua volta si appoggia sulla classe
package Dnd::Fourth::Power;
use strict;
use warnings;
use Dnd::Utils::Codes ;
sub new {
my $class = shift;
my $init = shift;
my $self = {};
bless $self, $class;
return $self;
}
sub print {
my $self=shift;
print W_USAGE();
}
1;
mi da un fantastico
Undefined subroutine &Dnd::Fourth::Power::W_USAGE called at
Dnd/Fourth/Power.pm line 17.
Secondo voi come mai?
Ovviamente avrete immaginato che il mio programma per come è strutturato è
fatto un modo da dare l'errore ...
Il giorno 31 marzo 2009 18.45, Oha <oha at oha.it> ha scritto:
> >Sfogliano CPAN, trovo per esempio Export::Lexical - non sono >sicuro che
> era quello a cui pensavo (quindi magari cerca >ancora su search.cpan.org),
> cmq, usando questo puoi fare
> > sub sub1 : ExportLexical { ... }
>
> equivale a Exporter::Simple da cui pasto un pezzo di synopsis:
> sub hello : Exported(greet,uk) { "hello there" }
> sub askme : Exportable { "what you will" }
> sub hi : Exportable(greet,us) { "hi there" }
>
> mi sembra inoltre che quest'ultimo sia piu' stabile/testato
>
> Oha
>
>
> _______________________________________________
> Firenze-pm mailing list
> Firenze-pm at pm.org
> http://mail.pm.org/mailman/listinfo/firenze-pm
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/firenze-pm/attachments/20090403/788a12cc/attachment.html>
More information about the Firenze-pm
mailing list