Tie::Subset - Tie an array or hash to a subset of another array or hash, respectively
use Tie::Subset; my %hash = ( foo=>11, bar=>22, quz=>33 ); tie my %subset, 'Tie::Subset', \%hash, ['bar','quz']; # same as tie-ing to 'Tie::Subset::Hash' my @array = (55,66,77,88,99); tie my @subset, 'Tie::Subset', \@array, [1,2,3]; # same as tie-ing to 'Tie::Subset::Array'
This class simply delegates to Tie::Subset::Hash or Tie::Subset::Array as appropriate. Please see the documentation of those modules.
Data::Alias
"Assigning to References" in perlref
Tie::StdScalar from Tie::Scalar
The module Tie::Subset::Array is primarily provided for orthogonality with Tie::Subset::Hash. The following "trick" can be used to get an array reference where the elements are aliases to the original array:
my $subset = sub { \@_ }->( @array[@indices] );
However, note there are differences between the behavior of this code and Tie::Subset::Array with respect to array indices that lie outside of the range of either array. For details, please see the file t/80_alias.t that is part of this module's distribution.
Copyright (c) 2018-2023 Hauke Daempfling (haukex@zero-g.net).
This library is free software; you can redistribute it and/or modify it under the same terms as Perl 5 itself.
For more information see the Perl Artistic License, which should have been distributed with your copy of Perl. Try the command perldoc perlartistic or see http://perldoc.perl.org/perlartistic.html.
perldoc perlartistic
To install Tie::Subset, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tie::Subset
CPAN shell
perl -MCPAN -e shell install Tie::Subset
For more information on module installation, please visit the detailed CPAN module installation guide.