so far i have done this but when i run it its not showing any results. And also I wanted to see those key and its values and use those values for some other purpose. Guys could any one please help me that would be really great. Thanks.#!/vol/perl/5.8/bin/perl use lib "/vol/perl/5.8/DBD/oracle9.2/lib/site_perl/5.8.1/sun4-solaris" +; $key="num"; $val=12; package NewHash; require Tie::Hash; use Carp; use vars qw(@ISA); @ISA = qw(Tie::StdHash); sub TIEHASH { my $class = shift; print $class; my %hash; @hash{@_} = (undef) x @_; return bless \%hash, $class; } sub STORE { my ($self, $key, $val) = @_; print $key,$val; if (exists $self->{$key}) { print $key,$val; $self->{$key} = $val; # croak "invalid key [$key] in hash\n"; return; } else{ print hhh; $self->{$key} = $val;} return; } sub FETCH { my $self = shift; my $key = shift; my $is_re = (ref $key eq 'Regexp'); return $self->{$key} if !$is_re && exists $self->{$key}; $key = qr/$key/ unless $is_re; /$key/ and return $self->{$_} for keys %$self; return; } package main; { my $b=new; $b->TIEHASH(NewHash); $a=NewHash->STORE('num',12); print "Package Type: ", ref($a), "\n"; print "$self->{$key}"; }
In reply to using Tie::Hash CPAN module by sudeep
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |