http://qs1969.pair.com?node_id=11130519


in reply to .env loading the dot env file?

.env is not standard in any traditional shell I am aware of, but that set is limited to: sh/bash and csh/tcsh.

If the format of that file indicates a standard shell "rc" type file with (for Bourne style), then I would not attempt to read it in your Perl program since it can contain anything the shell supports. The following is deceptive because it's just a basic shell script:

VAR="some value" export VAR

Rather, source it before your Perl program is invoked. This will do the right thing, and be available in %ENV.

If it's an ini format, use something like Config::Tiny - or whatever module is appropriate for the serialization format. Because that's all it is; don't invent your own. you would not do this for JSON, YAML, or XML - I hope :)

A few notes about understanding the %ENV in your Perl program; and assuming we're dealing strictly within the same process space on the same machine, etc:

The last thing I'll end with is, don't parse files that are meant to affect your shell environment in Perl. Use the shell to source it; then invoke your program. HTH