Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re^5: Can someone please write a *working* JSON moduleby dave_the_m (Monsignor) |
on Oct 27, 2021 at 10:47 UTC ( [id://11138102]=note: print w/replies, xml ) | Need Help?? |
I think it spawns a new interpreter rightIt definitely doesn't. eval BLOCK just pushes a 'EVAL' context onto the context stack, in a similar way that a sub call pushes a 'SUB' context, and a bare block pushes a 'LOOP_PLAIN' context. A context is just a type flag and a bit of saved state. On normal scope exit, the context is popped and the saved state restored (e.g. @_ restored on return from a sub). On an exception (die, croak etc), the perl interpreter keeps popping contexts (and restoring the saved state in each) until it hits an EVAL context or empties the context stack. The context stack is what caller() examines (in part). eval $string has a slow preceding step where it has to call the parser and compile the string into something resembling a sub, then it calls that 'sub' by pushing an EVAL context as with the block case. Benchmarks show that eval BLOCK has roughly the same overhead as calling a sub with no arguments. Dave.
In Section
Seekers of Perl Wisdom
|
|