in reply to Re: Refactoring a module with many anonymous subrefs as an OO module
in thread Refactoring a module with many anonymous subrefs as an OO module
Thanks!#!/usr/bin/perl use strict; use warnings; { package Foo; our %HASH; $HASH{blah} = sub { my $self = shift; print $self->{value}; }; sub new { bless { crefs => \%HASH, value => 'telcontar' } => shift + } sub access { my $self = shift; my $coderef = $self->{crefs}{+shift}; $self->$coderef(@_) } } my $x = Foo->new; $x->access('blah');
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Refactoring a module with many anonymous subrefs as an OO module
by Ovid (Cardinal) on Nov 21, 2007 at 20:13 UTC | |
by telcontar (Beadle) on Nov 22, 2007 at 09:38 UTC |