Tie::Indirect::* -- tie variables to access data located at run-time.
Each tied variable accesses data located by calling a sub which returns a reference to the data. The sub is called with parameters ($mutating, optional tie args...) where $mutating is true if the access may modify the value. tie $scalar, 'Tie::Indirect::Scalar', \&sub, optional tie args... tie @array, 'Tie::Indirect::Array', \&sub, optional tie args... tie %hash, 'Tie::Indirect::Hash', \&sub, optional tie args... EXAMPLE: my $dataset1 = { foo=>123, table=>{...something...}, list=>[...] }; my $dataset2 = { foo=>456, table=>{...something else...}, list=>[...] }; my $masterref; our ($foo, %table, @list); tie $foo, 'Tie::Indirect::Scalar', sub{ \$masterref->{$_[1]} }, 'foo'; tie %table, 'Tie::Indirect::Hash', sub{ $masterref->{$_[1]} }, 'table; tie @list, 'Tie::Indirect::Array', sub{ $masterref->{list} }; $masterref = $dataset1; ... $foo, %table, and @list now access members of $dataset1 $masterref = $dataset2; ... $foo, %table, and @list now access members of $dataset2
Jim Avera (jim.avera AT gmail) / Public Domain or CC0
To install Tie::Indirect, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tie::Indirect
CPAN shell
perl -MCPAN -e shell install Tie::Indirect
For more information on module installation, please visit the detailed CPAN module installation guide.