hi
you can do by array
sub m4
{
my ( $self,$args ) = @_;
# $args contains
# $args->{'bla'} = blub
# $args->['do'} = whatever
}
as call ( example )
$obj->m4 ({ bla => blub , do => whatever });
holger
Am 02.01.20 um 21:40 schrieb danieljb...@icloud.com:
What if you want named parameters? (i.e. sending a hash as your
argument)
sub m4
{
my $self = shift;
my %args = @_;
# and then optionally
my ($arg1, $arg2, $arg3) = @args{qw/arg1 arg2 arg3/};
# or you can just use $args{arg1}, etc...
}
On Thu, Jan 02, 2020 at 09:12:42PM +0100, Marc Espie wrote:
sub f
{
my ($arg1, $arg2) = @_;
... code
}
- three styles of parameter grab for methods:
sub m1
{
my $self = shift;
}
No other parameter.
sub m2
{
my ($self, $p1, $p2) = @_;
}
when getting all parameters (no check on the number usually)
sub m3
{
my $self = shift;
...
do_something_with(@_);
}
for functions with unlimited parameters after the first one