in reply to Re: Thread local variables in Thread::Pool::Simple
in thread Thread local variables in Thread::Pool::Simple

On a beginner's tangent, how would you call init() from $pool in the code above? My best guess is:

&{@{$pool->init}[0]}

$pool->init returns the arrayref which is dereferenced and accessed with enclosing @{} and trailing [0], returning the coderef, which is in turn dereferenced with enclosing &{}?

Replies are listed 'Best First'.
Re^3: Thread local variables in Thread::Pool::Simple
by ikegami (Patriarch) on Sep 19, 2009 at 13:53 UTC

    You can't. The object doesn't not provide a means of accessing the value you pass to init. But if it provided an accessor, I'm with Anonymous Monk: use arrows.

    Say the accessor is named "init",

    $pool->init # Returns the array ref passed to the constructor. ->[0] # Access to the first element of the referenced array. ->(); # Call the referenced sub.
Re^3: Thread local variables in Thread::Pool::Simple
by Anonymous Monk on Sep 19, 2009 at 07:48 UTC