my $cgi; sub hook { return if not $cgi->param(...); my (...) = @_; ... } $cgi = CGI->new(\&hook);