in reply to Not a CODE reference … my 1st script
This:
push( @device_thread, threads->new( \&thread_job( $key, $device_ip{$key}, $index ) )->join ) ;
Which obviously fails because the return value isn't a code reference, hence the error message.
Meaning that the calling thread would block waiting for the child thread to complete. Which would be exactly equivalent, but much more expensive that calling the function inline.
Is that what you intended, or were you meaning to push the thread handles onto the array call @device_thread?
Your code is so confused, that it is hard to know quite what your intention was, but I suspect that you might want:
push( @device_thread, threads->new( \&thread_job, $key, $device_ip{$key}, $index ) ); ... $__>join for @threads;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Not a CODE reference … my 1st script
by OneDreamCloser (Novice) on Apr 04, 2011 at 03:58 UTC |