Skip to content

Instantly share code, notes, and snippets.

@ktat
Created October 14, 2011 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ktat/1287614 to your computer and use it in GitHub Desktop.
Save ktat/1287614 to your computer and use it in GitHub Desktop.
add_to_items
# 問題では、add_to_items($value, \@array); でしたので、書き換わりません。
# と、指摘いただきました。
{
my ($value, $array_ref) = (1, [1,2,3,4]);
add_to_items($value, $array_ref);
print join ",", @$array_ref;
# 2,3,4,5
}
sub add_to_items {
my($value, $array_ref) = @_;
$_[1] = [ map { $_ + $value } @{$array_ref} ];
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment