#!/usr/bin/perl
#use strict; <<<< 末尾のprintを使用しなければ有効化して大丈夫。
package test;
{
my $count;
sub countup { $count++; $count; }
}
package main;
print &test::countup(), "\n";
print &test::countup(), "\n";
print &test::countup(), "\n";
print &test::countup(), "\n";
print '$count is not defined', "\n" if !defined($count);
print '$test::count is not defined', "\n" if !defined($test::count);
1 2 3 4 $count is not defined $test::count is not defined
只の"{}"でsubを囲む。lexical変数の場合、本当の意味で"機械的に"スコーピングしてくれる為、只の"{}"といえど、その中のmyはその中で保持される。これにより、"staticに見える"状況を創り出している。