#!/usr/bin/perl use strict; package Obj; sub new { my $class = shift; my $id = shift; return bless { id => $id }, $class; } sub method1 { my $self = shift; print "Object $self->{'id'}: Method 1\n"; } sub method2 { my $self = shift; print "Object $self->{'id'}: Method 2\n"; } package main; my $object1 = new Obj(1); my $object2 = new Obj(2); $object1->method1; $object1->method2; $object2->method1; $object2->method2; foreach my $var ( keys %{*Obj::} ) { no strict 'refs'; my $typeglob = *{"Obj::".$var}; next unless *$typeglob{CODE}; print $typeglob, " - ", ref $typeglob, "\n"; *$typeglob = sub { print "Blah!" }; } use Data::Dumper; print Dumper(%Obj::), "\n"; $object1->method1; $object1->method2; $object2->method1; $object2->method2;