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

R

Ronnie Laurikkala

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
 
J

Jürgen Exner

Ronnie said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top