Thanks Robert, That did the trick!
And I see my err, mutators take parameters, they don't take assignments >_< Thanks, Will On Sat, Dec 19, 2009 at 9:15 PM, Robert Boone <[email protected]> wrote: > You can change the line to: > > $self->{_mech} = WWW::Mechanize->new(); > > of > > $self->_mech(WWW::Mechanize->new()); > > > > > > On Sat, Dec 19, 2009 at 3:25 PM, Will Willis <[email protected]> > wrote: > > I'm using Moose to write a package that, among other things, connects to > the > > internet to fetch some content. > > The way I have my object designed is that want one of the attributes to > > contain a reference to a WWW::Mechanize object. > > ----the code--- > > #!/usr/bin/perl > > use strict; > > use Website; > > my $web = Website->new(name => 'Google', url => 'http://www.google.com/' > ); > > print "My Website's name is " . $web->name . "\n"; > > print $web->get_content(); > > > > ----the class--- > > package Website; > > use Moose; > > use WWW::Mechanize; > > has '_mech' => ( is => 'rw' ); > > has 'name' => ( is => 'rw', isa => 'Str', required => 1); > > has 'url' => (is => 'rw', isa => 'Str', required => 1); > > sub get_content { > > my $self = shift; > > $self->_mech = WWW::Mechanize->new(); > > $self->_mech->get($self->url); > > return $self->_mech->content; > > } > > 1; > > --- /end code -- > > That's not working , I get the following output/error: > > My Website's name is Google > > Can't modify non-lvalue subroutine call at Website.pm line 11. > > Do I need to make the '_mech' attribute be a (isa) > WWW::Mechanize object to > > achieve this? I have no intention of exposing any of WWW::Mechanize's > > functionality to the outside. I'm probably missing a small detail. Any > help > > would be appreciated. > > > > -Will > > _______________________________________________ > > Houston mailing list > > [email protected] > > http://mail.pm.org/mailman/listinfo/houston > > Website: http://houston.pm.org/ > > > _______________________________________________ > Houston mailing list > [email protected] > http://mail.pm.org/mailman/listinfo/houston > Website: http://houston.pm.org/
_______________________________________________ Houston mailing list [email protected] http://mail.pm.org/mailman/listinfo/houston Website: http://houston.pm.org/
