BEGIN { my $is_open = 0; sub check_openlog { if (not $is_open) { openlog(...) and ++$is_open; } } sub is_open { return $is_open; } }