in reply to Re^3: Variable will not stay shared in a sporadically crashing CGI
in thread Variable will not stay shared in a sporadically crashing CGI

I'd say the problem is inter-mixing lexicals my $cgi with package symbols like named subs like sub print_document

Changing to lexicals holding anonymous sub refs my $print_document = sub {} would solve the OP'S problem too.

Having persistent shared globals can be a desired effect. (Initialization overhead, communication channel)

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!