cached value !!

2001-07-26 Thread raptor

hi,

I have the following problem... a module/object that use a callback
func..example :

use Blah;
my $obj = new Blah(...);

..later on ...

my $firstcall = 1;
sub checkSomething {
if ($firstcall) {$firstcall = 0; return 0}
   code ...
};

$$obj{checkCode} = \checkSomething;

$obj-callSomemethod();

the problem is that during the invocations of the script the $firstcall
sometimes stays 0, instead to be initialised to 1 on every invocation of
the script  any ideas how can I cure this 

Thanx alot in advance...
=
iVAN
[EMAIL PROTECTED]
=




Re: cached value !!

2001-07-26 Thread Nouguier Olivier

raptor wrote:

 hi,

 I have the following problem... a module/object that use a callback
 func..example :

 use Blah;
 my $obj = new Blah(...);

 ..later on ...

 my $firstcall = 1;
 sub checkSomething {
 if ($firstcall) {$firstcall = 0; return 0}
code ...
 };

 $$obj{checkCode} = \checkSomething;

 $obj-callSomemethod();

 the problem is that during the invocations of the script the $firstcall
 sometimes stays 0, instead to be initialised to 1 on every invocation of
 the script  any ideas how can I cure this 

 Thanx alot in advance...
 =
 iVAN
 [EMAIL PROTECTED]
 =

cf manual:
http://perl.apache.org/guide/perl.html#my_Scoped_Variable_in_Nested_S

--
My mother always used to tell me, The early bird gets the worm.
The message seemed pretty clear to me: If you sleep late, you're
a lot less likely to be killed by a bird.
-- Elliott Downing






Re: cached value !!

2001-07-26 Thread raptor

thanx alot I also thought it has to be closure... but didn't done it in the
right way...
i.e. i was doing this way :) :

{
 my $firstcall = 1;
 sub checkSomething {
 if ($firstcall) {$firstcall = 0; return 0}
code ...
 };
}

but it has to be anonymous ...:)


 raptor wrote:

  hi,
 
  I have the following problem... a module/object that use a callback
  func..example :
 
  use Blah;
  my $obj = new Blah(...);
 
  ..later on ...
 
  my $firstcall = 1;
  sub checkSomething {
  if ($firstcall) {$firstcall = 0; return 0}
 code ...
  };
 
  $$obj{checkCode} = \checkSomething;
 
  $obj-callSomemethod();
 
  the problem is that during the invocations of the script the $firstcall
  sometimes stays 0, instead to be initialised to 1 on every
invocation of
  the script  any ideas how can I cure this 
 
  Thanx alot in advance...
  =
  iVAN
  [EMAIL PROTECTED]
  =

 cf manual:
 http://perl.apache.org/guide/perl.html#my_Scoped_Variable_in_Nested_S

 --
 My mother always used to tell me, The early bird gets the worm.
 The message seemed pretty clear to me: If you sleep late, you're
 a lot less likely to be killed by a bird.
 -- Elliott Downing