Re: Perl threads in Object Oriented code



On Mon, 30 Apr 2007 11:19:35 -0700, Eric wrote:


Note the following line of code in the former (non OO) script:

my $thr = threads->new(\&get);

This line is calling the 'get' sub. So, if I were to use the OO scripts
shown, how should I implement this?

I tried doing the obvious, which was to change the line to:

my $thr = threads->new($clock->get());

But I got the following error:

thread failed to start: Undefined subroutine &main::1177952602 called at
./CC.pl line 19.

Other failed attempts were:

my $thr = threads->new(\&clock->get()); my $thr =
threads->new(Clock::clock->get()); my $thr =
threads->new($Clock::get());

Truthfully, I am not well versed at Object Oriented Perl (or anything
else). So at this point I was making guesses that weren't so educated.

Does anyone have a solution?

Try (untested):
threads->new(sub { clock->get(); });
or
threads->new(Clock::get, clock);

Your problem is that the method wants a first parameter, the self
parameter or iow the object it is invoked on. You *have* to pass that
parameter, above are two ways of doing that.

HTH,
M4
.



Relevant Pages

  • Re: What am i doing wrong in calling this script? Urgent please. Thank You.
    ... > Sub btnFinish_Click ... > I just uploaded a web site and i am getting an error. ... > I have a script which sends form values to an email using AspNetEmail. ... > So i am calling the script in the wrong way. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: What am i doing wrong in calling this script? Urgent please. Thank You.
    ... I just uploaded a web site and i am getting an error. ... I have a script which sends form values to an email using AspNetEmail. ... Sub btnFinish_Click ... So i am calling the script in the wrong way. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: create a share folder on a remote computer
    ... > I have following script to create a share folder on a remote computer. ... Call Share.ExecMethod_("Create", InParam) ... Consult the VBScript documentation for the difference in calling syntax ... between calling a Sub versus a Function. ...
    (microsoft.public.windows.server.scripting)
  • Re: Perl threads in Object Oriented code
    ... Note the following line of code in the former script: ... This line is calling the 'get' sub. ... Am I missing something here? ...
    (comp.lang.perl.misc)
  • Re: SourceCode : perl OOPS by Conway:
    ... > for the book by Damien Conway on Object Oriented Perl. ... > My Plight is that i am not able to understand how the code snippets are ... > the name of the script that is available. ...
    (comp.lang.perl.misc)