in reply to .env loading the dot env file?

maybe tangential, but it's pretty easy to "source" a foreign rc-file (here bash) from Perl with this trick

my $bashcode=<<'__bash__'; . /tmp/src.sh; perl -MData::Dumper -e 'print Dumper \%ENV'; __bash__ my $VAR1; eval qx{bash -c "$bashcode"}; print $VAR1->{MONK};

original discussion: Re^3: How to "source" a shell file in Perl? (Trojan Dump)

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^2: .env loading the dot env file?
by perlfan (Parson) on Mar 28, 2021 at 20:01 UTC
    Very nice. The benefit here is that you don't have to do anything externally when invoking your script. Thank you and bookmarked :)
      Yes I like this inside-out approach too, since it's trivial to share data between different languages. :)

      BUT I should add that source has the same limitation like a do config.pl ... it's evaling code which might pose a bigger security problem than only "parsing" the file.

      OTOH that's also the case if the shell does it, before executing Perl.

      It wasn't clear to me what kind of .env the OP wants. And %ENV is always security relevant.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery