in reply to Perl equivelant to bash '$*'

How are calling the perl script? I would avoid calling an intermediate shell. If you execve() it directly you can preserve the whitespace in your binary argument. You'll be responsible for forming the argv[] array, though.

Replies are listed 'Best First'.
Re^2: Perl equivelant to bash '$*'
by tillywern (Initiate) on Jul 03, 2008 at 00:18 UTC
    The calling program has configurable settings that allow you to specify what program to start. It then starts that program and passes this C structure to it on the command line.

    Basically the calling program passes 128 bytes of data. It so happens that the fields in the structure are strings and padded with spaces but there are no delimiters other than byte offset from the beginning. So I know the data is there I just don't know how to get at it from within perl because I don't know how to treat the command line as a large blob of binary data.

    Basically the command line would look like this.
    program.pl <128 bytes of data>

    I'm only on the receiving side so it is a bit difficult. As you point out I could could put an intermediate shell script that does nothing but quote the original input and call the perl program but that seems a bit lame. It isn't that I can't implement a workaround, it is that I love the elegance of perl and thought there might be something I missed. A special variable or something like that.
      Pasting together the arguments is not going to work. Using $* only inserts one space between arguments. Just try this test program:
      #!/bin/bash echo "$*"
      Invoking the script as: script-name a b  c          d yields: a b c d

      From what you are saying, your program should only have one argument. You have to figure out why a shell is getting invoked.