ryangies has asked for the wisdom of the Perl Monks concerning the following question:
Example, "t-mypackage.pl" which uses "MyPackage.pm"package MyPackage; use strict; our $VERSION = 0; use Tie::Hash; use base qw(Tie::ExtraHash); # OO Interface sub new { my $class = ref($_[0]) || $_[0]; my $self = bless {}, $class; tie %$self, $class; } sub to_string { join ' ', %{$_[0]}; } # Tie interface sub STORE { $_[0][0]{$_[1]} = ucfirst($_[2]); } 1;
#!/usr/bin/perl -w use strict; use MyPackage; my $p = MyPackage->new(); $$p{Hello} = "world"; print $p->to_string, "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Blessing into the same package in class (object) and tie contexts
by Arunbear (Prior) on Mar 27, 2008 at 21:28 UTC | |
by ryangies (Initiate) on Mar 28, 2008 at 02:05 UTC | |
|
Re: Blessing into the same package in class (object) and tie contexts
by ikegami (Patriarch) on Mar 27, 2008 at 18:17 UTC | |
by ryangies (Initiate) on Mar 27, 2008 at 18:42 UTC |