christopher j bottaro wrote:
> hello,
> what are the equivalent of static vars in c code?  for instance...
>
> void myfunc() {
> static int first_call = 1;
>
> if (first_call) {
> /* do some intialization of something */
> first_call = 0;
> }
> }
>
> i want to be able to do something like that in perl...

"perldoc -q static" gives the answer.

BEGIN {
   my $first_call = 1;
   sub myfunc {
      if ($first_call) {
         # do some initialization of something
         $first_call = 0;
      }
   }
}





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to