NAME

Tie::Alias - create aliases in pure perl

SYNOPSIS

use Tie::Alias;
my $scalar = 'sad puppy';
tie my $alias, Tie::Alias => \$scalar;  # just like local *alias = \$scalar
$alias = 'happy puppy';
print $scalar,"\n";	# prints happy puppy

Alternately, and more simply

Tie::Alias::alias( $alias => $scalar );

or even

use Tie::Alias $alias => $scalar;

although that will work only at BEGIN time. Tie::Alias::alias can take any number of alias => original pairs, and does NOT take the backslash.

This module can be used to effect adding a reference onto @_ before a goto &EXPR, in case you ever need to do that

tie $_[@_], 'Tie::Alias' => $X; goto &NeedsPBR;

ABSTRACT

create aliases to lexicals, container members, what-have-you, through a tie interface. Aliases to variables that are already tied are done by returning the existing tie object. Aliases to object references, which are silly, are done by taking a reference to the object reference and using that as the base object of the Tie::Alias object.

DESCRIPTION

the Tie::Alias TIESCALAR function takes one argument, which is a reference to the scalar which is to be aliased. Since version 1.0, the argument no longer needs to be a reference. In case the scalar is already tied, the alias gets tied to whatever the scalar is already tied to also.

Tie::Alias works for scalars, arrays, and hashes.

tie @alias, 'Tie::Alias' => \@array;
tie %alias, 'Tie::Alias' => \%hash;

EXPORT

None, although Tie::Alias::alias is now available. Import it if you wish like so:

use Tie::Alias;
BEGIN { *alias = \&Tie::Alias::alias }

Or just use it in place:

use Tie::Alias;
Tie::Alias::alias \@alias => \@array, \%alias => \%hash, $alias => $scalar;

CHANGES

version 1.0 June 3 2007: Documenting the fallthroughs to hashes and arrays, which have been in place since 2002 but weren't described as actually working in the docs. Also adding use time invocation, although that will only work at BEGIN time, and combining the array and hash packages into this one file, and scrapping the placeholder support for aliasing handles.

SEE ALSO

perltie, Lexical::Alias, Data::Alias, Variable::Alias, Macrame

COPYRIGHT AND LICENSE

Copyright 2002, 2007 by david nicol davidnico@cpan.org

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.