Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Passing an array into an open command

by tcf22 (Priest)
on Mar 18, 2004 at 18:12 UTC ( #337751=note: print w/replies, xml ) Need Help??


in reply to Passing an array into an open command

It looks like it should work. I tried the following on Win32 Active Perl 5.8.

test1.pl
my @a; foreach(1..50){ $a[$_-1] = $_; } open(T, "test2.pl @a|"); while(<T>){ print; } close(T);

test2.pl
foreach(@ARGV){ print "$_\n"; }
If I run test1.pl, I get 1..50 printed out on seperate lines, just like you would expect.

UPDATE: Also works on Red Hat Linux 9. (Just change "test2.pl @a|" to "./test2.pl @a|" of course).

- Tom

Replies are listed 'Best First'.
Re: Re: Passing an array into an open command
by amw1 (Friar) on Mar 18, 2004 at 18:16 UTC
    with passing @a to the script would you run into limits of a commandline if @a is say 10,000 elements, or does the exec not care? (it's been a long time since I've played with this)
      Linux allows me to go up to around 23,000. Windows however crashed when i reach 530. I assume that there is some size or argument limit on most Oper. Systems.

      - Tom

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://337751]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2020-05-27 03:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (152 votes). Check out past polls.

    Notices?