|There's more than one way to do things|
Replacing environment variablesby loris (Hermit)
|on Oct 17, 2006 at 13:42 UTC||Need Help??|
loris has asked for the wisdom of the Perl Monks concerning the following question:
I'm sure I have asked this before, but I haven't been able to find where, so apologies for possibly repeating myself.
I have a file that contains environment variables. I want to create a new file in which the environment variables have been expanded. I could obviously get the template file line by line, look for things that look like environment variables, look these up in the %ENV hash, and replace the variable with the value if found. E.g.
This input looks (something) like this:
But I feel there must be a simpler way. Any ideas?
Update 1: Added code
Update 2: Added input
Update 3: Added missing case to input
"It took Loris ten minutes to eat a satsuma . . . twenty minutes to get from one end of his branch to the other . . . and an hour to scratch his bottom. But Slow Loris didn't care. He had a secret . . ."