How to pass Arrays

How to pass Arrays

am 24.11.2007 04:58:04 von amerar

Hi All,

I have a unix script which puts together an array:

set -A week_fnames $FILE5 $FILE6 $FILE7 $FILE8 $FILE9 $FILEA

How to I pass that array to a Perl program, and be able to use the
array in the Perl program??

Thanks!

Re: How to pass Arrays

am 24.11.2007 05:16:54 von Ben Morrow

Quoth "amerar@iwc.net" :
>
> I have a unix script which puts together an array:
>
> set -A week_fnames $FILE5 $FILE6 $FILE7 $FILE8 $FILE9 $FILEA
>
> How to I pass that array to a Perl program, and be able to use the
> array in the Perl program??

perl script "$week_fnames[@]" (or whatever the appropriate syntax is for
your shell) will pass the values into @ARGV in your perl program, but I
presume you could work that out... If you are trying to have your Perl
program change the values of the array in a shell script that invokes
it, then in general that can't be done. One way round is to have perl
emit shell code which you can then eval, but it can be tricky getting
the quoting right.

Ben