Ok.
Thank you.

-----邮件原件-----
发件人: 'Jesse Luehrs' [mailto:[email protected]] 
发送时间: 2010年11月9日 11:10
收件人: [email protected]
主题: Re: 答复: 答复: common build function

Moose::Policy has been deprecated for at least two years now, you should
really stop using it (I had no idea that it actually even still worked).
Check out MooseX::FollowPBP instead (and make sure to load it (and any
other Moose extensions) after Moose).

Also, please direct your emails to the mailing list, rather than to me
personally.

-doy

On Tue, Nov 09, 2010 at 11:03:44AM +0800, jiangys wrote:
> As follow, is a pm, is there any wrong?
> 
> package Corporate::Utils::Command::Mail;
> 
> use warnings;
> use strict;
> use v5.8.5;
> use Moose::Policy 'Moose::Policy::FollowPBP';
> use Moose;
> extends 'Corporate::Utils::Command';
> use Moose::Util::TypeConstraints;
> use Fatal qw( open close );
> use Cwd;
> use Mail::Sendmail;
> use Data::Dumper;
> $Data::Dumper::Indent = 3;
> use Corporate::Types;
> use version; my $VERSION = qv('0.01');
> 
> has 'to' => (is => 'rw', isa => 'Str', required => 1);
> has 'from' => (is => 'rw', isa => 'Str', required => 1);
> has 'subject' => (is => 'rw', isa => 'Str', required => 1);
> has 'body' => (is => 'rw', isa => 'Str', required => 1);
> 
> has 'utils' => (is => 'rw', isa => 'Corporate::Utils', required => 1);
> 
> sub send_email {
>         my $self = shift;
> 
>         my %mail = (    To      => $self->get_to(),
>                         From    => $self->get_from(),
>                         Subject => $self->get_subject(),
>                         Message => $self->get_body(),
>         );
> 
>         sendmail(%mail) or $self->get_utils()->mydie("error sending email
".
> $Mail::Sendmail::error);
> 
>         if ( $Mail::Sendmail::log ) {
>                 $self->get_utils()->mylog( "Mail log:
".$Mail::Sendmail::log
> );
>         }
> 
>         $self->get_utils()->mylog("Sent email to ".$self->get_to()." with
> subject ".$self->get_subject());
> 
>         return 1;
> }
> 
> no Moose;
> __PACKAGE__->meta->make_immutable;
> 
> 1;
> 
> All the error message is as follow
> 
> Moose is overwriting an existing method named meta in class
> Corporate::Utils::Command::Mail with a method which returns the class's
> metaclass. If this is actually what you want, you should remove the
existing
> method, otherwise, you should rename or disable this generated method
using
> the '-meta_name' option to 'use Moose'. at
> /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/Moose.pm line 205
>         Moose::init_meta('Moose', 'for_class',
> 'Corporate::Utils::Command::Mail', 'metaclass', 'undef', 'meta_name',
> 'meta') called at
> /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/Moose/Exporter.pm
> line 423
>         Moose::Exporter::__ANON__('Moose') called at
>
/home/auto/corporate_perl/Corporate/Utils/lib/Corporate/Utils/Command/Mail.p
> m line 12
>         Corporate::Utils::Command::Mail::BEGIN() called at
>
/home/auto/corporate_perl/Corporate/Utils/lib/Corporate/Utils/Command/Mail.p
> m line 12
>         eval {...} called at
>
/home/auto/corporate_perl/Corporate/Utils/lib/Corporate/Utils/Command/Mail.p
> m line 12
>         require Corporate/Utils/Command/Mail.pm called at
> /home/auto/corporate_perl/Corporate/Utils/lib/Corporate/Utils.pm line 70
>         Corporate::Utils::BEGIN() called at
>
/home/auto/corporate_perl/Corporate/Utils/lib/Corporate/Utils/Command/Mail.p
> m line 12
>         eval {...} called at
>
/home/auto/corporate_perl/Corporate/Utils/lib/Corporate/Utils/Command/Mail.p
> m line 12
>         require Corporate/Utils.pm called at
> /home/auto/oem/suse/lib/ReadUpdateinfo.pm line 86
>         ReadUpdateinfo::BEGIN() called at
>
/home/auto/corporate_perl/Corporate/Utils/lib/Corporate/Utils/Command/Mail.p
> m line 12
>         eval {...} called at
>
/home/auto/corporate_perl/Corporate/Utils/lib/Corporate/Utils/Command/Mail.p
> m line 12
>         require ReadUpdateinfo.pm called at ./build_suse.pl line 51
>         main::BEGIN() called at
>
/home/auto/corporate_perl/Corporate/Utils/lib/Corporate/Utils/Command/Mail.p
> m line 12
>         eval {...} called at
>
/home/auto/corporate_perl/Corporate/Utils/lib/Corporate/Utils/Command/Mail.p
> m line 12
> 
> 
> 
> 
> 
> 
> 
> On Tue, Nov 09, 2010 at 10:25:43AM +0800, jiangys wrote:
> > Thank you.
> > 
> > My class as follow:
> > 
> > package Corporate::Types;
> > use warnings;
> > use strict;
> > use v5.8.5;
> > use Moose;
> > use Moose::Util::TypeConstraints;
> > use Cwd;
> > use Carp;
> > #######################
> > ......some command......
> > #######################
> > no Moose;
> > __PACKAGE__->meta->make_immutable;
> > 1;
> > 
> > 
> > When I "use Corporate::Types" in the new pl, there is an error like "
> Moose
> > is overwriting an existing method named meta in class Corporate::Types
> with
> > a method which returns the class's metaclass. If this is actually what
you
> > want, you should remove the existing method, otherwise, you should
rename
> or
> > disable this generated method using the '-meta_name' option to 'use
> Moose'."
> 
> Nothing you've shown there is causing that - you'll have to show some
> more code to figure out what's going on.
> 
> -doy
> 

Reply via email to