#!/usr/local/bin/perl use strict; use warnings; my $array_ref = [1, 2, 3, 4]; my $hash_ref = { a => 1, b => 2 }; print $array_ref; print $hash_ref; my @a = @{ $array_ref }; my %a = %{ $hash_ref }; print @a; print %a; my @arr = (9,8,7,6); print @arr; sub func1 { return 'a'; } my $result = $func1(); # (1)引数に渡す値 my $num1 = 1; my $num2 = 2; # (2)サブルーチンの呼び出し my $total = total($num1, $num2); # (3)サブルーチンの定義 sub total { my ($num1, $num2) = @_; my $total = $num1 + $num2; return $total; }