develooper Front page | perl.beginners | Postings from May 2007

qx() won't accept over (about) 128,000 characters

Thread Next
Jameson C. Burt
May 15, 2007 08:50
qx() won't accept over (about) 128,000 characters
Message ID:
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
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!"' ;
   print qx(@manylines) ;
   # system(qq(@manylines)) ;   #Same problem.

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?

Jameson C. Burt, NJ9L   Fairfax, Virginia, USA
(202) 690-0380 (work)  magic "mysterious and awe-inspiring even though
                  we know they are real and not supernatural"

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About