in reply to variable interpolation from a filehandle
Would 'eval' work? Look up perldoc -f eval to see.
Update:
merlyn pointed out that I should be a little more helpful.
Here is the quick and dirty from the man page:
eval EXPR
eval BLOCK
In the first form, the return value of EXPR is
parsed and executed as if it were a little Perl
program. The value of the expression (which is
itself determined within scalar context) is first
parsed, and if there weren't any errors, executed
in the context of the current Perl program, so
that any variable settings or subroutine and
format definitions remain afterwards. Note that
the value is parsed every time the eval executes.
If EXPR is omitted, evaluates `$_'. This form is
typically used to delay parsing and subsequent
execution of the text of EXPR until run time.
In the second form, the code within the BLOCK is
parsed only once--at the same time the code
surrounding the eval itself was parsed--and
executed within the context of the current Perl
program. This form is typically used to trap
exceptions more efficiently than the first (see
below), while also providing the benefit of
checking the code within BLOCK at compile time.
.....
With an `eval', you should be especially careful
to remember what's being looked at when:
eval $x; # CASE 1
eval "$x"; # CASE 2
eval '$x'; # CASE 3
eval { $x }; # CASE 4
eval "\$$x++"; # CASE 5
$$x++; # CASE 6
Cases 1 and 2 above behave identically: they run
the code contained in the variable $x. (Although
case 2 has misleading double quotes making the
reader wonder what else might be happening
(nothing is).) Cases 3 and 4 likewise behave in
the same way: they run the code `'$x'', which does
nothing but return the value of $x. (Case 4 is
preferred for purely visual reasons, but it also
has the advantage of compiling at compile-time
instead of at run-time.) Case 5 is a place where
normally you would like to use double quotes,
except that in this particular situation, you can
just use symbolic references instead, as in case
6.
The short of it is this: Any perl code 'eval'ed is interpretted. You will have to figure out which fits for you.
J. J. Horner Linux, Perl, Apache, Stronghold, Unix jhorner@knoxlug.org http://www.knoxlug.org/
|
|---|