Hi Alex, Thanks for your reply. I have corrected the above errors, but still the .pm module is not able to capture the hash values. Please find the code as below.
use_tahash.pl use tahash; my %hash = ( "Jan" => 1, "Feb" => 2, "Mar" => 3, ); #my $val = tahash->new(\%hash); my $val = tie(%hash,"tahash") or die "Can't tie : $!"; tahash.pm --------- use strict; use warnings; package tahash; #sub new { # my $class = shift; # tie my %ref, $class; # bless \%ref, $class; # } sub TIEHASH { print "<@_ \n>"; my $class = shift; my %hash = @_; print "In TIEHASH .... \n"; return bless(\%hash); } sub DESTROY { print "The object is destroyed...\n"; } 1;
The output is something as below:
<tahash >In TIEHASH .... The object is destroyed...
I was unable to capture the hash values in .pm TIEHASH method. Please help.
In reply to Re^2: How to tie a hash to a class
by pavanpvss
in thread How to tie a hash to a class
by pavanpvss
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |