jk2addict has asked for the wisdom of the Perl Monks concerning the following question:
The question is simple, but fun. :-)
What can I say, I'm a curious sort.
Assuming your module has a ->new() and ->printme() method, and you want to pass options into it, what is your favorite method of doing so and why? I would still say that these are options that are getting passed after the core parameters for a method are passed.
my $foo = Foo->new(autothis => 1, delimthat => '::'); $foo->printme('text', align => 'vertical', font => 'Arial'); package Foo; sub new { my ($class, %args) = @_; ... }; sub printme { my ($self, $text, %args) = @_; ... };
my $foo = Foo->new( {autothis => 1, delimthat => '::'} ); $foo->printme('text', {align => 'vertical', font => 'Arial'}); package Foo; sub new { my ($class, $args) = @_; }; sub printme { my ($self, $text, $args) = @_; ... };
Is this strictly a form over function issue, or are there and good reasons to prefer one over the other?
edited: Mon Aug 19 23:26:50 2002 by jeffa - closed ul tag
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: What's your favorite method of passing parameters into a sub?
by sauoq (Abbot) on Aug 19, 2002 at 20:42 UTC | |
|
Re: What's your favorite method of passing parameters into a sub?
by blokhead (Monsignor) on Aug 19, 2002 at 21:27 UTC | |
|
Re: What's your favorite method of passing parameters into a sub?
by Abigail-II (Bishop) on Aug 20, 2002 at 12:58 UTC | |
by jk2addict (Chaplain) on Aug 20, 2002 at 14:55 UTC | |
by Abigail-II (Bishop) on Aug 20, 2002 at 15:30 UTC | |
|
Re: What's your favorite method of passing parameters into a sub?
by jk2addict (Chaplain) on Aug 20, 2002 at 00:35 UTC | |
|
Re: What's your favorite method of passing parameters into a sub?
by vek (Prior) on Aug 19, 2002 at 20:20 UTC |