italdesign has asked for the wisdom of the Perl Monks concerning the following question:

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.