かみぽわーる

kamipo's blog

スカラーのコピーのリファレンス

arrayとhashのコピーのリファレンスは
[]と{}で簡単に作れるけど、

scalarのコピーのリファレンスってどうやるんだろ。
5分ほど悩んでこれぐらいしか思いつかんかった。

#!/usr/bin/perl -l
use strict;
use warnings;

local $, = q{, };

my @array  = (1, 2, 3); 
my %hash   = (a => 1, b => 2); 
my $scalar = '123abc';

print \@array,  [@array];
print \%hash,   {%hash};
print \$scalar, \"$scalar";