Perl example of inside-out object number 2 code=yes # object oriented example - inside out # tags #perl #programming #objectoriented # http://perldoc.perl.org/perlobj.html#Inside-Out-objects ##### test-time.pl #!/usr/bin/perl -wT use Hash::Util::FieldHash 'fieldhash'; require '../lib/Time.pm'; my $time = Time->new; print $time->epoch . "\n"; ################ # Time.pm package Time; use strict; use warnings; use Hash::Util::FieldHash 'fieldhash'; fieldhash my %time_for; sub new { my $class = shift; my $self = bless \( my $object ), $class; $time_for{$self} = time; return $self; } sub epoch { my $self = shift; return $time_for{$self}; } 1;