in reply to best way to pass data

There are much, much better ways. The command you listed is enough to make most people cringe (myself included).

Passing the whole array as an argument on the command line will probably fail. There's simply a limit to how long the argument list can be, and I doubt it can have newlines.

Here's a quick solution (many others are possible):

Make the recieving script read from STDIN (ie. while(<>) { chomp; print; }).

Then instead of backtics, use open.

# Note the | here. This allows you to write to your script open(SCRIPTS, "| /tmp/scripts.pl") or die; foreach my $line (@ARRAY) { print SCRIPTS $line . "\n"; } close SCRIPTS;

Hope this helps,

~J

Replies are listed 'Best First'.
Re: Re: best way to pass data
by Anonymous Monk on Aug 23, 2003 at 04:27 UTC
    Sorry to be stupid here but how do I get the recieving script to put the stuff into an array to use? I am sending a web page to the second script to process. Ive tried: $uploader = $query->upload("infile"); while (<$uploader>){ push (@import_files, $uploader); } And while (<>){ push (@import_files, shift;); } and six or seven varants, please help. Thanks Rishard
      Found this here:
      http://dbforums.com/arch/95/2002/6/400241
      Basically
      ##Master
      ...some code...
      system ("./slave.pl @array");
      ...end code...

      ##Slave
      @import_array = @ARGV;
      ...code...

      rishard
        Responding to my own post because I only half solved the problem. From Master.pl to Slave.pl, I am sending a bundle of XML files with headers. Since the stuff is passed via the "command line", the XML header errors out so the stuff does not make it to the Slave.pl. I have loaded String::Escape () and still cannot get the information to the array in Slave.pl. Can someone tell me the proper escape proceedure so all the array data arrives intact?
        rishard