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)
| [reply] [d/l] [select] |
This is getting a bit off-topic, but some globals are ok. Novice programmers don't always know when they're safe and when they aren't, and they're often too timid to change a global to a local when it really needs to be done. That's why we advise people not to use globals at all. But CGI is probably safe as a global, because there's no reason to have two of them in your program. | [reply] |
But CGI is probably safe as a global, because there's no reason to have two of them in your program.
I absolutely agree with the general comment about some globals being ok if the coder knows what they are doing - but we are talking about mod_perl here, better to play it safe, and lexicals are arguably safer* in this case.
* Update: "safer" not in the sense of security, but in less chances for things to go wrong.
| [reply] |