in reply to One piece of code, two mysteries! (UPDATED.)
async BLOCK; "async" creates a thread to execute the block immediately followin +g it. This block is treated as an anonymous subroutine, and so must have a semicolon after the closing brace. Like "threads->create()" +, "async" returns a *threads* object. $thr->error() Threads are executed in an "eval" context. This method will return "undef" if the thread terminates *normally*. Otherwise, it returns the value of $@ associated with the thread's execution status in i +ts "eval" context.
eval? eval returns undef on failure, so I write
and I getprint timedCommand( 3, $cmd, $_ ) || "\$@ $@" for 2, 3, 4; ### LINE B +###
$ perl huh 1 2 2 1 2 3 3 1 2 3 4 4
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: One piece of code, two mysteries!
by BrowserUk (Patriarch) on Oct 05, 2012 at 06:57 UTC | |
|
Re^2: One piece of code, two mysteries!
by Anonymous Monk on Oct 05, 2012 at 06:46 UTC | |
|
Re^2: One piece of code, two mysteries!
by Anonymous Monk on Oct 05, 2012 at 06:37 UTC |