Data::Alias

Comprehensive set of aliasing operations
Download

Data::Alias Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Matthijs van Duin
  • Publisher web site:
  • http://search.cpan.org/~xmath/

Data::Alias Tags


Data::Alias Description

Comprehensive set of aliasing operations Aliasing is the phenomenon where two different expressions actually refer to the same thing. Modifying one will modify the other, and if you take a reference to both, the two values are the same.Aliasing occurs in Perl for example in for-loops and sub-calls: for $var ($x) { # here $var is an alias to $x } foo($y); sub foo { # here $_ is an alias to $y }Data::Alias is a Perl module that allows you to apply "aliasing semantics" to a section of code, causing aliases to be made whereever Perl would normally make copies instead. You can use this to improve efficiency and readability, when compared to using references.SYNOPSIS use Data::Alias; alias { # aliasing instead of copying whenever possible }; alias $x = $y; # alias $x to $y alias @x = @y; # alias @x to @y alias $x = $y; # similar for array and hash elements alias push @x, $y; # push alias to $y onto @x $x = alias ; # construct array of aliases alias my ($x, $y) = @_; # named aliases to arguments alias { ($x, $y) = ($y, $x) }; # swap $x and $y alias { my @t = @x; @x = @y; @y = @t }; # swap @x and @y use Data::Alias qw/ alias copy /; alias { copy $x = $y }; # force copying inside alias-BLOCK use Data::Alias qw/ deref /; my @refs = (\$x, \@y, \%z); foo(deref @refs) # same as foo($x, @y, %z) Requirements: · Perl


Data::Alias Related Software