giulienk has asked for the wisdom of the Perl Monks concerning the following question:
Is there any better way to code the last part of the method where i just put every remaining hash value into the object?sub new { my ($self, $key, $value); my $class = shift; my ($intpref, $prefix, $telnum, $smstext, %hash) = @_; $self = bless { 'intpref' => $intpref, 'prefix' => $prefix, 'telnum' => $telnum, 'smstext' => $smstext, 'cookie_jar' => exists $hash{cookie_jar} ? delete $hash{cookie_jar} : "lwpcookies.txt", }, $class; for (($key, $value) = each %hash) { $self->{$key} = $value; } $self; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Optional parameters in new() method
by Kanji (Parson) on Oct 26, 2001 at 00:09 UTC | |
|
Re: Optional parameters in new() method
by dragonchild (Archbishop) on Oct 25, 2001 at 23:21 UTC | |
|
Re: Optional parameters in new() method
by tomhukins (Curate) on Oct 25, 2001 at 23:20 UTC |