to do? Please provide a sample of the output you're trying to get.$a=1; $b=2; .... while ($line = <INFILE>) { chomp($line); # contains $a, $b print "$line\n"; #prints "$a" "$b"
It's not clear what you are trying to achieve. See I know what I mean. Why don't you?
If you read text to print it later, you print text. If you want to replace text (eg. "$a" with "1"), do so with s/\$a/1/ - see perlre.
If you want perl to evaluate the file, say so with eval, do or require. Evaluating a file whilst reading it linewise is tricky and outright impossible if those lines aren't self-contained perl statements (e.g. if the file contains control structures spanning several lines).
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
In reply to Re: Making perl evaluate a variable with a string
by shmem
in thread Making perl evaluate a variable with a string
by moked
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |