Method call
examples/perloop/person07/lib/Person.pm
package Person; use strict; use warnings; sub new { my ($class, %args) = @_; my $self = \%args; bless $self, $class; return $self; } sub lname { my ($self, $value) = @_; return $self->{lname}; } sub marry { my ($self, $other) = @_; return $self->{lname} = $self->{lname} . '-' . $other->lname; } 1;
examples/perloop/person07/script/wedding.pl
use strict; use warnings; use v5.10; use Person; my $man = Person->new( lname => 'Bar' ); my $woman = Person->new( lname => 'Foo' ); say $man->lname; # Bar say $woman->lname; # Foo $woman->marry($man); say $man->lname; # Bar say $woman->lname; # Foo-Bar