package DFA; sub new { my $dfa = {}; bless $dfa, shift; # associates $dfa with the current package $dfa->{buffer} = ''; $dfa->{output} = []; # note: output is now an array reference $dfa->{states} = {}; # note: states is now a hash ref $dfa; # return the new object } ...