Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
The other method uses perl oo to use the package's constructor to store the variable values.package Temp; sub test { my ($params)=@_; print "$params"; } ###main code use Temp; Temp->test("some param");
Aside from a syntaxical errors, both of these methods should and do produce the same results. I'm wondering which is the method of choice, especially if I start passing roughly 6 params to packaged subroutines.package Temp; sub new { my ($class,$params)=@_; my $self={}; $self->{param}="$params"; bless($self,$class); return $self; } sub test { my ($self)=@_; my $param=$self->{param}; print "$param"; } ###main code use Temp; my $obj=Send->new("some param"); $obj->test();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(Ovid) Re: Most Efficient
by Ovid (Cardinal) on Jan 16, 2001 at 02:44 UTC | |
|
Re: Most Efficient
by gildir (Pilgrim) on Jan 16, 2001 at 17:42 UTC |