in reply to Reading from txt makes variables literal?
Why aren't the variables being used as variables if it's read from a file?
Because Perl treats text as text unless you specifically tell it to treat it in some other way.
Perl is manipulating the text file in exactly the way you've requested; it's opening the text file, slurping it into an array, and then printing the array which contains the text. That's what you've asked it to do. If you want it to do something with the text, such as interpreting it as code, you'll have to tell Perl to do that too. For that, there is the do command, or require, or eval, to name a few options. None of them should be given carte blanch power to execute text that comes from untrusted sources. But that's another topic...
The point is that Perl can do pretty much what you want, but you're just not asking it to do what you want.
Imagine if Perl's default behavior was to treat a text file as code the instant you read it into memory. What a mess that would be!
Dave
|
|---|