- or download this
sub name {
my $self = shift;
if (@_) {
...
}
return $self->{name};
}
- or download this
$person->name; # get the name
$person->name("Ovid"); # set the name
- or download this
$person->name(qw/Publius Ovidius Naso/);
# or
$person->name([qw/Publius Ovidius Naso/]);
# or
my $name = Name->new("Publius Ovidius Naso");
$person->name($name);
- or download this
sub name {
my $self = shift;
if (1 == @_ && ! ref $_[0]) {
...
croak "Unknown arguments to name()";
}
}
- or download this
sub name($self) {
return $self->{name};
}
...
$self->{name} = $name;
return $self;
}
- or download this
use Sub::Signatures;
sub foo($bar) {
...
foo(1); # prints 1
foo(1,2); # prints 1, 2
foo(1,2,3); # fatal error