#!/usr/bin/env perl use strict; use warnings; use 5.10.0; { package Foo; use Moo; has 'attr1' => ( is => 'rw' ); has 'attr2' => ( is => 'rw' ); sub hallo { my( $self, $str, $ref ) = @_; return sprintf '%s : %s - %s', $str, $self->attr1, $self->attr2; } } my $foo = Foo->new( { attr1 => 8, attr2 => 'c' } ); say $foo->hallo( 'welt', { attr1 => 9, attr2 => 'd' } );