performance Re: string not block Re: SPUG: interpolating into a string variable

Brian Hatch bri at
Sun Dec 21 09:53:48 CST 2003

> Interestingly, my brain-dead workaround seems to perform slightly better
> than eval

Not suprising at all.  Your solution (which required you knew the
potential variable names) was all already-compiled perl code.  A
few substitutions with hash lookups, etc.

Eval (or s///e) requires that perl read your code and compile
it internally before running it - an expensive operation.
No doubt it's slower.  It's more robust (no need to know what's
in the string first) but it's slow.

However the 'my' in the eval case may be slowing things
down too - it's not only setting the value, it's making
scoping decisions.

Brian Hatch                  "This product is defective.
   Systems and                It only holds one baby."
   Security Engineer         -- Bree, looking in baby magazines,       shortly after learning we're
                                having twins...
Every message PGP signed
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url :

More information about the spug-list mailing list