shrawansher has asked for the wisdom of the Perl Monks concerning the following question:

i have a perl that executes variable number of processes and stores the log files after each process..Depending on the scenario, there can be multiple log files.The script looks for certain error codes in all the log files and store them in an array.My question is is there any way to pass the array to another perl script as an argument while updating it after each file ? Basically what i am trying to achieve is to get the last updated error list and when the script runs the currently updated error list so that i can print the difference being the errors in the files formed currently.
  • Comment on passing an array to another perl script and update

Replies are listed 'Best First'.
Re: passing an array to another perl script and update
by bart (Canon) on Aug 16, 2011 at 12:25 UTC
    I don't get why you make it separate scripts, I'd just let one script both scan for errors and do something with that list.

    Otherwise, you'll have to serialize the array to pass it to the other script. Traditionally there are a few approaches: if they're typically all a single word, just pass them along the command line. Or you could pipe the array, one item per text line, into the second script. Or if all that fails, dump it in a serialized format (flat text file, CSV, JSON, XML, Data::Dumper, or Storable) and and pass that, either by pipe or in a file of which you pass the filename, to the second script.

Re: passing an array to another perl script and update
by Anonymous Monk on Aug 16, 2011 at 06:30 UTC
    You should store the codes in a file, and pass the path of that file as an argument, see @ARGV , Getopt::Long
Re: passing an array to another perl script and update
by jdrago999 (Pilgrim) on Aug 18, 2011 at 01:17 UTC

    Have you considered using subroutines instead of different entire perl scripts?

Re: passing an array to another perl script and update
by Anonymous Monk on Aug 18, 2011 at 09:01 UTC