Jeff Pinyan > Tie-Autotie > Tie::Autotie

Download:
Tie-Autotie-0.03.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.03   Source  

NAME ^

Tie::Autotie - Automatically ties underlying references

SYNOPSIS ^

  use Tie::Autotie
    'Tie::Module',      # the module to autotie
    [ 'use', 'args' ],  # arguments to 'use Tie::Module'
    [ 'tie', 'args' ];  # arguments to tie() for Tie::Module

  # then use Tie::Module as usual

DESCRIPTION ^

This module allows you to automatically tie data structures contained in a tied data structure. As an example:

  use Tie::Autotie 'Tie::IxHash';

  tie my(%hash), 'Tie::IxHash';

  $hash{jeff}{age} = 22;
  $hash{jeff}{lang} = 'Perl';
  $hash{jeff}{brothers} = 3;
  $hash{jeff}{sisters} = 4;

  $hash{kristin}{age} = 22;
  $hash{kristin}{lang} = 'Latin';
  $hash{kristin}{brothers} = 1;
  $hash{kristin}{sisters} = 0;

  for my $who (keys %hash) {
    print "$who:\n";
    for my $what (keys %{ $hash{$who} }) {
      print "  $what = $hash{$who}{$what}\n";
    }
  }

This program outputs:

  jeff:
    age = 22
    lang = Perl
    brothers = 3
    sisters = 4
  kristin:
    age = 22
    lang = Latin
    brothers = 1
    sisters = 0

You can see that the keys of %hash are returned in the order in which they were created, as well as the keys of the sub-hashes.

BUGS ^

AUTHOR ^

Jeff japhy Pinyan, <japhy@pobox.com>

COPYRIGHT AND LICENSE ^

Copyright (C) 2004 by japhy

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.3 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: