in reply to printing enviroment vars from regex
Firstly, the environment variables are accessed via the %ENV hash - so you need to get them from there. Secondly, you've escaped the variable in the replacement string so you'll only get the name of the variable. Remove the escaping to get the value of the variable.
And a couple of style points - you can make your life easier by using the empty file input operator to save all the hassle of opening and closing files and also there's no need to use the binding operator if you're doing a substitution on $_.
while(<>) { s/\$([A-Z]+)/$ENV{$1}/g; print $_; }
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
|
|---|