Problem...I am defining my subroutines at the beginning of my program, and Perl
is executing the subroutine at compile time before it is actually called.....I
don't think this is proper behaviour...e.g.
open (LOG, ">/tmp/log");
sub nearlyfatallywounded ($) {
my $ERRMSG=$_[0];
print LOG "The Error is: $ERRMSG\n";
warn "$ERRMSG\n";
}
nearlyfatallywounded("Legitimate Error");
close;
When compiled returns the following:
The Error is:
The Error is: Legitimate Error
Aside from doing the following nasty hack:
my $notreally=1;
open (LOG,">/tmp/log");
sub nearlyfatallywounded ($) {
my $ERRMSG=$_[0];
unless ($notreally == 1) {
print LOG "This is the error: $ERRMSG\n";
warn "This is the error: $ERRMSG\n";
}
}
$notreally=0;
nearlyfatallywounded "This is a Legitimate Error.";
close;
How do I keep the subroutine from being executed just because it is being
parsed?
_______________________________________________
Perl-Unix-Users mailing list. To unsubscribe go to
http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users