On 4/11/07, Jen mlists <[EMAIL PROTECTED]> wrote:
But my error_report function is located in a package,not the main script.
Then how to use a global variable for label it?
You may use a true global by giving its full name, say $main::header_is_complete, even from another package and under 'use strict'. Or you could make a subroutine that you call whenever you need to make sure that the header is output, something like this: my $header_is_complete; # starts out false sub ensure_header { return if $header_is_complete; my($q) = @_; print $q->header(); $header_is_complete = 1; } Because the 'my' variable is declared outside the subroutine, it retains its value from one invocation to the next. Its scope continues until the end of the enclosing file (since there's no enclosing block), so it's available to some code even though it's not globally accessible. Cheers! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/