Hi,
I have been playing around with the 'tie' operator and basically I want be able to 'dump' the object using Data::Dumper.
In the code specifically in the line,
print Dumper \%test;
Nothing is dump at all. I am not sure why. I read somewhere that I should treat variables binded by the tie operator as normal variables. So, normally the above syntax should show me the content of the hash. Any thoughts?
Below is the code.
#!/usr/bin/perl
use strict;
use Data::Dumper;
tie( my %test, 'Sample_Tie_Class' );
$test{'hello'} = 'hi';
print "$test{'hello'}\n";
print Dumper \%test;
package Sample_Tie_Class;
use strict;
sub TIEHASH {
my $class = shift;
bless { 'value' => {}, }, $class;
}
sub STORE {
my ($self, $key, $value) = @_;
$self->{'value'}->{$key} = $value;
}
sub FETCH {
my ($self, $key) = @_;
return $self->{'value'}->{$key};
}
sub FIRSTKEY {
}