DeusVult has asked for the wisdom of the Perl Monks concerning the following question:
Now let us say that I right the following script:This is the time: $variable
This script is, of course, spectacularly useless. One might think that it would print "This is the time: -insert time here-". One would be wrong. It prints "This is the time: $variable".#!/usr/bin/Perl -w use strict; # as always open ( FILE, "input.txt" ) or die ( "input.txt: $!" ); my $variable = localtime; while (<FILE>) { print $_; }
Obviously, I could just write the script to say print localtime;, but that isn't what I'm really trying to do. I just need, in general, the ability to interpolate one level deeper. So the question I have for you, O monkish fonts of everlasting wisdom, is this:
How do I convince Perl to evaluate the values of the variables that are contained in a string that I read from a file?
Some people drink from the fountain of knowledge, others just gargle.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Digging interpolation deeper
by OeufMayo (Curate) on Feb 06, 2001 at 21:58 UTC | |
Re: Digging interpolation deeper
by eg (Friar) on Feb 06, 2001 at 21:58 UTC | |
Re: Digging interpolation deeper
by davorg (Chancellor) on Feb 06, 2001 at 22:01 UTC | |
Re: Digging interpolation deeper
by jeroenes (Priest) on Feb 06, 2001 at 22:02 UTC | |
Re: Digging interpolation deeper
by MeowChow (Vicar) on Feb 06, 2001 at 22:30 UTC | |
Re: Digging interpolation deeper
by mr.nick (Chaplain) on Feb 06, 2001 at 23:39 UTC | |
Re: Digging interpolation deeper
by gryphon (Abbot) on Feb 06, 2001 at 23:31 UTC | |
Re: Digging interpolation deeper
by MrNobo1024 (Hermit) on Feb 07, 2001 at 05:47 UTC | |
Re: Digging interpolation deeper
by azatoth (Curate) on Feb 06, 2001 at 22:01 UTC |