Many systems will not allow you to pass so much data on the commandline. And as you have it written, it's very insecure -- all the contents of
@ARRAY are interpolated and sent to the shell to be executed. What if
@ARRAY contained something like
" ;; rm -rf / ;; " ? With the simplistic backticks, the special characters (and you say you're dealing with "lines of code" in
@ARRAY -- you'll get in trouble at least by the first semicolon) will cause too many problems.
A better way would be to pass this data in a pipe:
open my $fh, "|/tmp/scripts.pl"
or die "Can't pipe scripts.pl: $!";
## send the data to script.pl:
print $fh @ARRAY;
## or:
print $fh join "\n", @ARRAY;
## or probably best:
print $fh $_ for @ARRAY;
## or, depending on what's exactly in @ARRAY:
print $fh "$_\n" for @ARRAY;
Then have script.pl read in the data from its STDIN. If it can process this data as it comes in (instead of needing all the data before doing its thing), then the last two options above will be the most efficient, as they send one element of the array at a time to script.pl.
Whether this is the best way, I don't know. But it is a much better way than trying to have thousands of lines of code interpolated within backticks!
blokhead
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.