Skip to content

Instantly share code, notes, and snippets.

@ejhayes
Created November 17, 2011 18:26
Show Gist options
  • Select an option

  • Save ejhayes/1374000 to your computer and use it in GitHub Desktop.

Select an option

Save ejhayes/1374000 to your computer and use it in GitHub Desktop.
Perl modify arguments by reference
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
sub t1 {
my ($v) = @_;
$$v = {hey => "you", there => 'me'};
}
my $v = {some => 'value'};
print Dumper($v);
#$VAR1 = {
# 'some' => 'value'
# };
t1(\$v);
print Dumper($v);
#$VAR1 = {
# 'there' => 'me',
# 'hey' => 'you'
# };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment