#!/usr/bin/perl -w package Flub; use strict; use Class::Multimethods; sub new { my ($class) = @_; bless { _flub => $_[1] || "", }, $class; } # new multimethod flubble => ('*') => sub { my ($self) = shift; return $self->{_flub}; }; multimethod flubble => ('$') => sub { my ($self) = shift; $self->{_flub} = shift; return $self->{_flub}; }; package main; use strict; my $f = Flub->new("Cheese is Good."); print "Trying to display \$f->{_flub}: " . $f->flubble() . "\n"; print "Trying to assign Cheese is Bad to \$f->{_flub}: " . $f->flubble("Cheese is Bad ") . "\n";