in reply to Passing array pointer through script input

You can't, not like this. Perl opens a shell (or a pipe) to execute the back ticks, so it's only text that goes "over the wire".

`perl myscript.pl \@arr` would actually pass a literal @arr to myscript.pl.

To pass any data structure except strings you first have to convert them to string, by serializing them.

Replies are listed 'Best First'.
Re^2: Passing array pointer through script input
by ikegami (Patriarch) on Aug 21, 2008 at 21:20 UTC

    There are three places along the path where stringification is forced, but none are related to pipes.

    1. `...` is a form of string literal. A string is created from its contents. `...` is the same thing as readpipe("...").
    2. If the shell is required, then the "..." in "`...`" is a shell command, which can only be a string.
    3. Arguments are passed to the child via a variant of the exec system call, which only accepts strings.
      Arguments are passed to the child via a variant of the exec system call, which only accepts strings.

      That's where I thought the pipes where involved - to read the output of the exec'ed command, perl has to open a pipe to it, which I thought would replace the exec call altogether. But my C fu is rusty to inexistent...

        The problem is with the arguments, not the output.