How to source variables and values from a file, like in UNIX sh scripts?

Discussion in 'Perl' started by Ronnie Laurikkala, Dec 18, 2003.

  1. In e.g. a Bourne shell script I can source variables and values;
    #!/bin/sh
    .. ${HOME}/script_common_lib

    How can I source variables and values from a file
    and use them in Perl-scripts?

    Perl-"pseudo code":
    ...
    source("${HOME}/script_common_lib");
    $logfile = $A_LOG_FILE;
    ...
    print "Log file name: ", $logfile;
    ...

    And in the file '${HOME}/script_common_lib' contains e.g.:
    ...
    export A_LOG_FILE=/tmp/foo.log
    ...

    Best Regards,
    Ronnie
     
    Ronnie Laurikkala, Dec 18, 2003
    #1
    1. Advertising

  2. Ronnie Laurikkala wrote:
    > How can I source variables and values from a file
    > and use them in Perl-scripts?


    Depending on what you want to do:
    perldoc - f use
    perldoc -f do
    perldoc -f require

    jue
     
    Jürgen Exner, Dec 18, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jan Danielsson
    Replies:
    8
    Views:
    644
    Mike Meyer
    Jul 22, 2005
  2. Jp Calderone
    Replies:
    0
    Views:
    467
    Jp Calderone
    Jul 21, 2005
  3. Patrick Kowalzick
    Replies:
    5
    Views:
    485
    Patrick Kowalzick
    Mar 14, 2006
  4. davidj411
    Replies:
    0
    Views:
    551
    davidj411
    Jun 27, 2008
  5. Replies:
    13
    Views:
    553
    Anno Siegel
    Sep 10, 2007
Loading...

Share This Page