定数を使う


 constantモジュールを使います。
use constant AAA => 'aaa';
use constant BBB => 100;
use constant CCC => 24 * 60 * 60;
use constant YYY => [100, 200, 300];
use constant ZZZ => {a => 'A', b => 'B'};

print AAA, "\n";
print BBB * 10, "\n";
print CCC, "\n";
print YYY->[1], "\n";
print ZZZ->{a}, "\n";
 まとめて書くこともできます。
use constant {
	AAA => 'aaa',
	BBB => 100,
	CCC => 24 * 60 * 60,
	YYY => [100, 200, 300],
	ZZZ => {a => 'A', b => 'B'},
};

関連項目

定数を使う2
列挙型