can we source a shell script in perl script

前端 未结 7 843
隐瞒了意图╮
隐瞒了意图╮ 2021-01-15 04:54

can we source a shell script in the perl script??

Example: Program 1:

cat test1.sh
#!/bin/ksh
DATE=/bin/date

program 2:

<         


        
7条回答
  •  情书的邮戳
    2021-01-15 05:24

    Yes, you can now do this with the Env::Modify module.

    use Env::Modify qw(:ksh source);
    source("./test1.sh");     # env settings from test1.sh now available in Perl
    print `$ENV{DATE}`;       # print `/bin/date`;
    

提交回复
热议问题