![]() |
|
Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: .env loading the dot env file?by Corion (Patriarch) |
on Mar 28, 2021 at 09:08 UTC ( [id://11130501]=note: print w/replies, xml ) | Need Help?? |
See Get default login environment and the discussion therein. There is Shell::EnvImporter. I'm not sure if you really want the effects of a shell script, or just something that "looks like sh environment commands". If so, your approach seems good, but doesn't respect quoted constructs. In your code, I would at least change the split() to a more robust parser, so that it also understands foo=bar=baz as setting foo to bar=baz:
Support for foo="bar=baz" and foo=\"bar=baz\" would also be addable, but if you want to support multiline values, you'll have to switch away from line-based parsing. Updated: The capturing parentheses were missing for the key, spotted by Anomalous Monk
In Section
Seekers of Perl Wisdom
|
|