Passing PERL var values to SH Shell Script

Greetings all,

 If I have a SH script that calls a PERL script in the following way:
perl $HOME/scripts/config.properties

And in the config.properties PERL file, this Perl script only sets a number of environmental parameters in the following way:

#!/usr/bin/perl
$VAR1 = (
     'PECOSSource' => '/opt/tibco/incoming',
     'PECOSDestination' => '/opt/apsproc/implementation/TIBCO',
     'PECOSArchive' => '/opt/apsproc/tibco/archive/incoming',
     'PECOSFileName' => 'PECOS_Input_1.xml'
     ...
     'PECOSResArchive' => '/opt/apsproc/tibco/archive/outgoing');

If my SH shell script executes the config.properties PERL script, how can my SH shell script access the following PERL-defined parameters such as: PECOSSource, PECOSDestination, PECOSArchive, PECOSFileName, and PECOSResArchive?? Any further guidance would be greatly appreciated.

Thanks,

Patrick Q

You can't. Variables don't work that way.

You could perhaps execute a perl script to print the values in a way the shell can understand, then source those values.

Try it this way and see if this is what you want:

$ cat perl1.pl
#!/usr/bin/perl
$ENV{'PECOSSource'}        =  "/opt/tibco/incoming";
$ENV{'PECOSDestination'}   =  "/opt/apsproc/implementation/TIBCO";
$ENV{'PECOSArchive'}       =  "/opt/apsproc/tibco/archive/incoming";
$ENV{'PECOSFileName'}      =  "PECOS_Input_1.xml";
$ENV{'PECOSResArchive'}    =  "/opt/apsproc/tibco/archive/outgoing";

printf( "%s %s %s %s %s\n", $ENV{'PECOSSource'}, $ENV{'PECOSDestination'}, $ENV{'PECOSArchive'}, $ENV{'PECOSFileName'}, $ENV{'PECOSResArchive'} );

$ cat shell1.sh
#!/usr/bin/ksh
perl1.pl | read PECOSSource PECOSDestination PECOSArchive PECOSFileName PECOSResArchive

echo $PECOSSource
echo $PECOSDestination
echo $PECOSArchive
echo $PECOSFileName
echo $PECOSResArchive

$ shell1.sh
/opt/tibco/incoming
/opt/apsproc/implementation/TIBCO
/opt/apsproc/tibco/archive/incoming
PECOS_Input_1.xml
/opt/apsproc/tibco/archive/outgoing

Should be noted that only works in ksh, other shells will set the variables in a subshell.