open(@_): Do not expect to get ARRAY(0x88a4c0) arguments

K

kj

I've written a script that is supposed to serve as a wrapper around
an existing command-line utility (which I'll call "foobar" below).
This utility has a very rich and complex set of command-line options,
so, in order to have the wrapper script follow the original utility's
calling conventions as closely as possible, while bypassing the
shell, I had the line

open my $out, '|-', 'foobar', @ARGV or die $!;

....but open complains with

Internal error: open(@_): Do not expect to get ARRAY(0x88a4c0) arguments

I can avoid the error if instead I use

open my $out, "|foobar @ARGV" or die $!;

....but this can lead to errors (e.g. if one of the original arguments
is a quoted string with embedded whitespace).

Is this a bug in the design of open, or a feature?

More importantly, is there a way around this problem?

TIA!

Kynn
 
K

kj

In said:
I've written a script that is supposed to serve as a wrapper around
an existing command-line utility (which I'll call "foobar" below).
This utility has a very rich and complex set of command-line options,
so, in order to have the wrapper script follow the original utility's
calling conventions as closely as possible, while bypassing the
shell, I had the line
open my $out, '|-', 'foobar', @ARGV or die $!;
...but open complains with
Internal error: open(@_): Do not expect to get ARRAY(0x88a4c0) arguments

I found the problem. It seems to be a bug in autodie...

Kynn
 
E

Eric Pozharski

I found the problem. It seems to be a bug in autodie...

Not for me

perl -wle '
open $out, q{|-}, q{/bin/ls}, qw(-s -i /) or die;
print while(<$out>);
close $out;
wait;'
total 92
112225 4 bin 20 0 initrd.img 320641 4 root
464929 4 boot 13 0 initrd.img.old 368737 4 sbin
448897 4 cdrom 160321 8 lib 1 0 sys
480961 4 cdrom0 11 16 lost+found 2 8 tmp
679 0 dev 496993 4 media 2 4 usr
384769 8 etc 304609 4 mnt 2 4 var
128257 4 floppy 432865 4 opt 18 0 vmlinuz
2 4 home 1 0 proc 12 0 vmlinuz.old

Looking at your headers: Ubuntu, Hardy Heron? So, I believe,
perl5.10.0 (just a guess). Right?

So here we go different ways -- your code fails for you, but succedes
for me; please, provide complete minimal example and exact error
messages you've got. (That means -- copy-paste.)
 
P

Peter J. Holzer

^^^^^^^

Not for me

perl -wle '
open $out, q{|-}, q{/bin/ls}, qw(-s -i /) or die;
print while(<$out>);
close $out;
wait;'

You didn't use autodie, so how does this show the absence of a bug in
autodie?

hp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top