Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Tie::No_Ref_Hash;
- use strict;
- use warnings;
- our $VERSION = v1.0;
- use parent qw (Tie::Hash);
- sub prohibit_ref ($key) {
- die q (Attempt to use reference as a key)
- if ref $key;
- }
- sub TIEHASH {
- my ($class) = @_;
- bless { }, $class;
- }
- sub FETCH {
- my ($self, $key) = @_;
- prohibit_ref ($key);
- return $self->{$key};
- }
- sub STORE {
- my ($self, $key, $value) = @_;
- prohibit_ref ($key);
- return $self->{$key} = $v;
- }
- sub DELETE {
- my ($self, $key) = @_;
- prohibit_ref ($key);
- return delete $self->{$key};
- }
- sub EXISTS {
- my ($self, $key) = @_;
- prohibit_ref ($key);
- return exists $self->{$key};
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement