You should really read Tie::Hash
Anyway, to give you a start here is an example: #! /usr/bin/perl -l
use strict;
use warnings ;
package Remember;
use strict;
use warnings;
sub TIEHASH {
my $class = shift ;
return bless {}, $class;
}
sub STORE {
my ( $self, $key, $value) = @_ ;
$self->{$key}= $value ;
}
sub FETCH {
my ( $self, $key) = @_ ;
return $self->{$key} ;
}
package main;
my %fred;
tie %fred, 'Remember' ;
$fred{'abc'} = 'xyz' ;
print "$fred{'abc'}";
|