[dcross@acxiom.co.uk: Tie::Hash::Cannabinol]

Chris Benson chrisb at jesmond.demon.co.uk
Wed Jun 6 13:53:25 CDT 2001


>From the London.pm list!

----- Forwarded message from Cross David - dcross <dcross at acxiom.co.uk> -----

From: Cross David - dcross <dcross at acxiom.co.uk>
To: "'london-pm at lists.dircon.co.uk'" <london-pm at lists.dircon.co.uk>
Subject: Tie::Hash::Cannabinol
Date: Wed, 6 Jun 2001 10:54:52 +0100
Reply-To: london-pm at lists.dircon.co.uk


Once an idea gets into my head, the only way to shake it off is to go away
and write it :)

Dave...

package Tie::Hash::Cannabinol;

use strict;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);

require Exporter;
require Tie::Hash;

@ISA = qw(Exporter Tie::StdHash);
@EXPORT = qw();
@EXPORT_OK =();

$VERSION = '0.01';

sub FETCH {
  my $self = shift;

  my @keys = keys %$self;

  return $self->{$keys[rand $#keys]};
}

sub EXISTS {
  return rand > 0.5;
}

1;
__END__

=head1 NAME

Tie::Hash::Cannabinol - A hash on hash!

=head1 SYNOPSIS

  use Tie::Hash::Cannabinol;
  my %h;

  tie %h, 'Tie::Hash::Cannabinol';

=head1 DESCRIPTION

The idea of writing a tied hash called T::H::C was just too good to ignore.

You can store values in this hash just as you would a normal hash, but
when you ask for a value back, you get any random value from the hash.

The C<exists> function isn't really to be trusted either :)

=head1 AUTHOR

Dave Cross <dave at dave.org.uk>

=head1 SEE ALSO

perl(1).

perltie(1).

=cut


The information contained in this communication is
confidential, is intended only for the use of the recipient
named above, and may be legally privileged. If the reader 
of this message is not the intended recipient, you are
hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited.  
If you have received this communication in error, please 
re-send this communication to the sender and delete the 
original message or any copy of it from your computer
system.

----- End forwarded message -----

-- 
Chris Benson



More information about the Tyneside-pm mailing list