{
my %working_dir_of;
}
sub get {
...
}
####
my %working_dir_of;
sub get {
...
}
##
##
#!/usr/bin/perl
use strict;
my %hash = ( foo => 'bar');
sub meth {
my ($h,$k) = @_;
my $string = sprintf 'print $%s{%s},"\n"', $h, $k;
eval $string;
};
meth('hash','foo');
__END__
bar
##
##
my( %dbh_of, %dir_of, ...);
my %props = (
dbh => \%dbh_of,
dir => \%dir_of,
...
);
sub get {
my($self,$attr) = @_;
my $return_val;
# if valid attribute, return the object's value
if( defined $props {$attr} ) {
return $props {$attr} -> { refaddr $self};
}
# otherwise, carp a warning
else {
carp("Invalid attribute '$attr'");
}
}