in reply to Link methods to hash values
As I understand it, doing it by hand would be something like:
my %hash; sub get_name { my $subname = (caller 0)[3]; $subname =~ s/.*::get_//; print $hash{$subname}, "\n"; } $hash{'name'} = 'Herk'; get_name;
But I believe the best way would be to resort to some CPAN module. I haven't done much OO programming but I think Class::Accessor will fit.
Update: Changed v10 to "\n". I always use v10 in quick tests because it's easier to type.
--
David Serrano
|
|---|