FamilyConnect wrote:
> 
> 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?

Works fine for me.  Fix that close line to 'close LOG;' - not that it should 
change the result.

-- 
  ,-/-  __      _  _         $Bill Luebkert   ICQ=14439852
 (_/   /  )    // //       DBE Collectibles   Mailto:[EMAIL PROTECTED] 
  / ) /--<  o // //      http://dbecoll.tripod.com/ (Free site for Perl)
-/-' /___/_<_</_</_     Castle of Medieval Myth & Magic http://www.todbe.com/
_______________________________________________
Perl-Unix-Users mailing list. To unsubscribe go to 
http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users

Reply via email to