Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Hi monks. Been programming Perl for several years but just stumbled upon Moose. Anyway, I have a script ( that instantiates an object of a class ( that uses a role ( The problem is when I pass a hash ref to Wget->new(), it's not being received correctly. Here is the relevant parts of the code.

use Module::Load; my $class = 'DTF::Wget'; load $class; my $adapter = $class->new( 'input_line' => $input_line, 'dl_base_dir' +=> $dl_base_dir, 'report_file' => $report_file );

package DTF::Wget; use strict; use warnings; use Moose; with 'DTF::Transfer';

package DTF::Transfer; use strict; use warnings; use Moose::Role; sub BUILD {} after 'BUILD' => sub { my $self = shift; die scalar(keys %$self); }

If all worked, the die statement in the role would print 3, since I passed 3 key-value pairs to the constructor of the class that uses the role. However, it prints 0. $self has absolutely nothing. I tried several variations of this, including moving the BUILD to The result is always the same - $self is empty. I'm probably missing something obvious. Would appreciate any pointers.

In reply to Moose::Role not getting params passed via ->new() by italdesign

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2023-03-31 21:47 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (76 votes). Check out past polls.