Help needed in calling path file from Perl script.

Hi All,
I need help in accessing a path file (path.xyz_pqr) not having a shell shebang and exporting paths in the following syntax,

export DB_SCRIPT_PATH="/abc/aash/scripts/db_scripts/xyz_pqr"
export SRC_FILES_DIR="/bcd/fdw/incoming/xyz_pqr"

I need to use the path contained in the DB_SCRIPT_PATH variable.
Tried using system, `` and exec also referred to earlier posts like

but could not get it working. :wall:
The path.xyz_pqr file works when called using ./path/of/path.xyz_pqr file on the command prompt but not through my perl script.
I am currently working on /usr/bin/sh shell. Please help m ein calling this path file in my Perl script and using the DB_SCRIPT_PATH variable in my Perl script for getting the path stored in it.
Thanks :b:

If you need to set env vars in your perl script , try:

use Env;
$ENV{DB_SCRIPT_PATH}="/abc/aash/scripts/db_scripts/xyz_pqr"
$ENV{SRC_FILES_DIR}="/bcd/fdw/incoming/xyz_pqr"

If i need set the Env vars in the Perl script itself then what is the use of exporting it from the Path file? Need to get the values of exported variables into the Perl script.

I think my system calls are not working fine....need help with that...
:frowning:

Reverse logic:

# export MY_VAR="test_var"
#cat test.pl
#!/usr/bin/perl
use Env;
print "VAR:".$ENV{MY_VAR}."\n";
# test.pl                 
VAR:test_var

Hey Klashxx...I fully agree with the concept that you have used here but i need to call an already existing file that exports these path variables. I just need to call that file.

I need help with calling this file path.xyz_pqr with variables getting exported in it.
Replies are highly appreciated.
Thanks.

I am using hardcoded values for time being but have to get the path variables from the file having Paths dclared in variables.

Need help... please let me know in case any further details are needed.

Thanks.

A possible workaround inside your perl:

->Read your profile file -> Look for the export VAR=VALUE pattern ->
->Get the var & values to be imported and use ENV .

Thanks Klashxx.

I found the solution. I am calling my Perl script with a Shell script, that executes tha path file. Later i used ENV to call the paths which are exported in the Path file.
Thanks for replying. :slight_smile:

Glad you solved it!