Jameson C. Burt wrote:
> Within Perl, I construct programs in other programming languages 
> and submit the result to a Unix (Linux or IBM AIX) operating system
> with 2GB to 8GB memory.
> I submit such a program to the operating system using Perl's
>   qx()
> Unfortunately, giving qx() over 128,420 characters (about and can vary
> by a few characters) then returns nothing.
> Yet, giving qx() 128,000 characters gets properly executed by the
> operating system.
> 
> Following is an example, 
> expedited from my original test that actually had 1270 lines.
> Only with fewer lines (eg, replace 1370 by 1269) will this program output
>    "Last line of large program!"
> Here's the program that constructs 
> and tries giving qx() over 128,000 characters of code:
>    #!/usr/bin/perl -w
>    $shorty = ' ' x 99   .   '#'   .   "\n" ;  #100/101 characters
>    #Repeat 1370 lines of $shorty into @manylines:
>    # foreach $i (0..1269)  {$manylines[$i] = $shorty} ;  #Succeeds
>    foreach $i (0..1370)    {$manylines[$i] = $shorty} ;
>    $manylines[$#manylines + 1] =  'echo "Last Line of large program!"' ;

You can simplify that to:

my @manylines = ( ( ' ' x 99 . "#\n" ) x 1371, 'echo "Last Line of large
program!"' );


>    print qx(@manylines) ;
>    # system(qq(@manylines)) ;   #Same problem.

Your line of code is a comment (The # character starts a comment in shell)
which is why nothing is returned:

$ perl -e'
my @manylines = ( ( " " x 99 . "#\n" ) x 1371, q[echo "Last Line of large
program!"] );
print [EMAIL PROTECTED];
' | wc
      0       0       0
$ perl -e'
my @manylines = ( ( " " x 99 . "\n" ) x 1371, q[echo "Last Line of large
program!"] );
print [EMAIL PROTECTED];
' | wc
      1       5      28
$ perl -e'
my @manylines = ( ( " " x 99 . "\n" ) x 1371, q[echo "Last Line of large
program!"] );
print [EMAIL PROTECTED];
'
Last Line of large program!


> However, appending the following lines to the above code
> will properly execute those 1370  lines.  
>    open(OUTFILE, ">/tmp/zz.out") ;
>    print(OUTFILE  @manylines) ;
>    close(OUTFILE) ;
>    system("bash /tmp/zz.out") ;
> While I can run this latter code, it both adds more code 
> and adds a file to the operating system's filesystem.
> 
> Can qx() accept large numbers of characters,
> perhaps using some simple technique?

When it is saved as a file the shell (bash) ignores the comment lines.



John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to