Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Re: setting perl ENV from file

by flounder99 (Friar)
on Sep 16, 2003 at 17:09 UTC ( [id://291880]=note: print w/replies, xml ) Need Help??


in reply to Re: setting perl ENV from file
in thread setting perl ENV from file

This works for simple cases but is not very robust.
use Data::Dumper; my %envron; while (<DATA>) { chomp; my ($key, $value) = /(.+)=(.*)/; next unless defined $key; $value =~ s/\$(\w+)/$environ{$1}/g; $environ{$key} = $value; } print Data::Dumper->Dump([\%environ], ["*environ"]); __DATA__ myfile=test.log mydir=/kelly/$myfile longdir=/$myfile$mydir __OUTPUT__ %environ = ( 'longdir' => '/test.log/kelly/test.log', 'mydir' => '/kelly/test.log', 'myfile' => 'test.log' );

--

flounder

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://291880]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-23 22:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found