Importing environment variables to Perl

后端 未结 3 1208
甜味超标
甜味超标 2021-01-15 03:33

I\'m not sure if importing is the right word to use. I\'m a beginner in both Perl and Bash. I have set a variable on Bash, so when I do:

echo $PRDIR
         


        
3条回答
  •  有刺的猬
    2021-01-15 03:58

    Another solution to use the variable directly in perl :

    In the shell :

    $ export PRDIR=foobar
    

    In perl :

    #!/usr/bin/perl
    
    use Modern::Perl;
    
    use Env qw/PRDIR/;
    
    say $PRDIR;
    

提交回复
热议问题