http://qs321.pair.com?node_id=895225

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

Hello,
I would like to extends a package in order to have some default values.

The module I would like to extend is WWW::Selenium .

I would like to extend the package in my code, just to have some defualt values.
Ususally you call WWW::Selenium like this:
my $b=Selenium->new( host => "localhost", port => 4444, browser => "*firefox", browser_url => 'http://www.google.co +m', );
I would like to call it just with new, without args:
So I tried to write an extension:
package Selenium; our $VERSION=0.01; use 5.010; use Moose; use MooseX::NonMoose; use Test::WWW::Selenium; extends 'Test::WWW::Selenium'; around BUILDARGS => sub { my $orig = shift; my $class = shift; my %args = ( @_ == 1 ? %{ $_[0] } : @_ ); $args{host}//="localhost"; $args{port}//=4444; $args{browser}//="*firefox"; $args{browser_url}//='http://wwww.google.com'; return $class->$orig(%args); }; sub BUILD { my $self = shift; #$self->start; }


But it doesn't work. Without arguments I have an error.
Where I'm wrong?