use strict; use warnings; use 5.010; use Data::Dumper; # Modify Attribute my $mod_att = sub{ my $self = shift; my $ref = shift; $self->{att1} = $ref->{att1}; $self->{att2} = $ref->{att2}; }; # vereinfachter Konstruktor my $m = bless{ mod_att => $mod_att, att1 => 8, att2 => 'c' }, __PACKAGE__; sub hallo{ my $self = shift; my $str = shift; my $ref = shift; $self->{mod_att}->($self, $ref) if $ref; return sprintf "%s : %s - %s", $str, $self->{att1}, $self->{att2}; } say $m->hallo('Welt'), "\n", $m->hallo('Welt', {att1 => 9, att2 => 'd'}), "\n", Dumper $m;