Skip to content

Instantly share code, notes, and snippets.

@kenjiskywalker
Created May 1, 2012 10:02
Show Gist options
  • Save kenjiskywalker/2566967 to your computer and use it in GitHub Desktop.
Save kenjiskywalker/2566967 to your computer and use it in GitHub Desktop.
reference!!!!
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
my @hoge;
my $answer;
my $foo = {
x => 1,
y => 2,
};
push(@hoge,$foo);
my $bar = {
x => 3,
y => 4,
};
push(@hoge,$bar);
my $baz = {
x => 5,
y => 6,
};
push(@hoge,$baz);
print " === no reference === \n";
print Dumper @hoge;
# 配列として渡す
# $VAR1 = {
# 'y' => 2,
# 'x' => 1
# };
# $VAR2 = {
# 'y' => 4,
# 'x' => 3
# };
# $VAR3 = {
# 'y' => 6,
# 'x' => 5
# };
print " === reference === \n";
print Dumper \@hoge;
# リファレンスを与えればスカラとしてデータを渡せる
# $VAR1 = [
# {
# 'y' => 2,
# 'x' => 1
# },
# {
# 'y' => 4,
# 'x' => 3
# },
# {
# 'y' => 6,
# 'x' => 5
# }
# ];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment