On 4/11/07, Tom Phoenix <[EMAIL PROTECTED]> wrote:
snip
my $header_is_complete; # starts out false
sub ensure_header {
return if $header_is_complete;
my($q) = @_;
print $q->header();
$header_is_complete = 1;
}
snip
Is there a reason you are not using an our variable instead of a my variable:
sub ensure_header {
our $header_is_complete;
return if $header_is_complete;
my($q) = @_;
print $q->header();
$header_is_complete = 1;
}
Or even better using a block to hide that variable from other functions:
{ #keep $header_is_complete private to this function
my $header_is_complete;
sub ensure_header {
return if $header_is_complete;
my($q) = @_;
print $q->header();
$header_is_complete = 1;
}
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/