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. Advertisements

  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. Advertisements

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. Cloud Burst
    Replies:
    11
    Views:
    1,512
  2. Jan Danielsson
    Replies:
    8
    Views:
    903
    Mike Meyer
    Jul 22, 2005
  3. chris
    Replies:
    0
    Views:
    398
    chris
    Oct 13, 2006
  4. Patrick Kowalzick
    Replies:
    5
    Views:
    707
    Patrick Kowalzick
    Mar 14, 2006
  5. kgk
    Replies:
    1
    Views:
    385
    Marc 'BlackJack' Rintsch
    Jul 11, 2007
  6. William McBrine
    Replies:
    1
    Views:
    555
    Tim Golden
    Mar 16, 2008
  7. davidj411
    Replies:
    0
    Views:
    781
    davidj411
    Jun 27, 2008
  8. Replies:
    13
    Views:
    793
    Anno Siegel
    Sep 10, 2007
Loading...