Using a hash in that fashion is generally referred to as dispatching and the hash is a "dispatch table". Contrast the technique with more usual Perl OO:
use strict; use warnings; package Counter; sub new { my ($class, $start) = @_; return bless {count => $start}, $class; } sub add { my ($self, $value) = @_; $self->{count} += $value; } sub get { my ($self) = @_; return $self->{count}; } package main; my $ctr = Counter->new (7); print "Start: " . $ctr->get () . "\n"; $ctr->add (3); print "End: " . $ctr->get () . "\n";
In reply to Re: OOP By Any Other Name
by GrandFather
in thread OOP By Any Other Name
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |