If you're paranoid about what kind of data someone's going to pass in, you can always filter it.sub new { my $class = shift; my $self = { @_ }; return bless($self, $class); } # ... my $test = Foo->new(handle => $dbh); my $handle = $test->{handle};
This will restrict parameters to those in the import list. You could extend this to produce errors, of course.my @imports = qw [ foo bar ]; sub new { my ($class, %params) = @_; my %self; @self{@imports} = @params{@imports}; return bless(\%self, $class); }
In reply to Re: Initial Variables
by tadman
in thread Initial Variables
by Angel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |