Sourcing shell scripts in Perl -


i want source shell script within perl , have environment variables available in perl, i'm not sure if there's elegant way it. obviously, using system() won't work since runs in forked process, , environment changes lost. think there's cpan module can it, prefer not use external modules.

i've seen 2 solutions not work in case:

  1. have wrapper calls shell script, , calls perl script. not know ahead of time of shell scripts need call.

  2. manually opening shell script , scraping arg=value pairs. won't work either because shell script not simple list of arg=value, rather contain bunch of conditionals, , variables can have different values depending on conditions.

sh -c "source script; env" should output environment @ end of script name=value pairs, can parse perl script (as perl language made parsing, should easy).


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -