#! /usr/bin/perl -w use strict; use warnings; use feature qw(say); my $hoge = 1; my @hoge = (0, 1, 2, 3); my $ret = double(\$hoge); say $$ret; my @ret = double(\@hoge); say join( ", ", @{ $ret[0] }, ); sub double { my $reference = shift; my $type = ref $reference; if ($type eq "SCALAR") { ${$reference} *= 2; } elsif ($type eq "ARRAY") { @{$reference} = map { $_ * 2 } @{$reference}; } else { warn "something wrong"; } return $reference; }