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

Discussion in 'Perl Misc' started by kj, Oct 22, 2008.

  1. kj

    kj Guest

    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
    --
    NOTE: In my address everything before the first period is backwards;
    and the last period, and everything after it, should be discarded.
    kj, Oct 22, 2008
    #1
    1. Advertising

  2. kj

    kj Guest

    In <gdndh7$e6p$> kj <> writes:

    >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
    --
    NOTE: In my address everything before the first period is backwards;
    and the last period, and everything after it, should be discarded.
    kj, Oct 22, 2008
    #2
    1. Advertising

  3. On 2008-10-22, kj <> wrote:
    > In <gdndh7$e6p$> kj <>
    > writes:
    >
    >>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...


    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.)
    --
    Torvalds' goal for Linux is very simple: World Domination
    Eric Pozharski, Oct 22, 2008
    #3
  4. On 2008-10-22 21:13, Eric Pozharski <> wrote:
    >> 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;'


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

    hp
    Peter J. Holzer, Oct 26, 2008
    #4
  5. On 2008-10-26, Peter J. Holzer <> wrote:
    > On 2008-10-22 21:13, Eric Pozharski <> wrote:
    >>> 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;'

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


    Yup, it doesn't.

    --
    Torvalds' goal for Linux is very simple: World Domination
    Eric Pozharski, Oct 26, 2008
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. niz
    Replies:
    2
    Views:
    1,923
    Simon Andrews
    Jul 23, 2003
  2. TR
    Replies:
    1
    Views:
    390
    John Saunders
    Dec 14, 2004
  3. Simon Strandgaard

    how to expect eof with expect+pty

    Simon Strandgaard, Dec 20, 2006, in forum: Ruby
    Replies:
    4
    Views:
    353
    Simon Strandgaard
    Dec 20, 2006
  4. ruud

    Perl Expect send array

    ruud, Feb 22, 2005, in forum: Perl Misc
    Replies:
    2
    Views:
    202
  5. Phil
    Replies:
    0
    Views:
    167
Loading...

Share This Page