Perl Variable Aliases

When a variable is passed by value, Perl does not create a copy of the contents to build @_ but, rather, creates an alias to the contents of the original variable. Therefore, a memory blow-up is caused by reading from @_.

#!/usr/bin/perl

use strict;
use warnings;
use English qw(-no_match_vars);
use locale;

my $variable = 'data';
implicit_pass_by_reference($variable);
print $variable . "n";

sub implicit_pass_by_reference {
    my $argument = $_[0];
    $$argument = 'new data';
}
Feedback is always welcome! If you'd like to get in touch with me concerning the contents of this article, please use Twitter.