Michael G Schwern wrote:

>On Tue, Jul 19, 2005 at 10:45:34AM -0700, Piotr Fusik wrote:
>  
>
>>The problem is that the arguments passed to exec() are not passed
>>as they are to the called program, but instead are split on whitespace.
>>
>>Example:
>>perl -e "exec$^X,'-e','print+join+q{,},@ARGV','foo boo bar'"
>>prints:
>>foo,boo,bar
>>
>>system() works fine:
>>perl -e "system$^X,'-e','print+join+q{,},@ARGV','foo boo bar'"
>>prints:
>>foo boo bar
>>    
>>
>
><snip>
>
>  
>
>>Configured by ActiveState at Mon Mar 31 00:45:28 2003.
>>
>>Summary of my perl5 (revision 5 version 8 subversion 0) configuration:
>>    
>>
>
>Thank you for your report.
>
>That's an old version of Perl.  Try upgrading and see if the bug is still 
>present.
>
I see the same behaviour using current perls.

It appears that you need to add some double quotes into the string that 
becomes the exec'd programs @ARGV:

perl -e "exec$^X,'-e','print+join+q{,},@ARGV',q{\"foo boo bar\"}"

prints

foo boo bar

as expected.

(You can also use the same idea to avoid the need for the ugly + signs 
in your -e one-liner:

perl -e "exec $^X, '-e', q{\"print join ',', @ARGV\"}, q{\"foo boo bar\"}"

also works fine.)



------------------------------------------------
Radan Computational Ltd.

The information contained in this message and any files transmitted with it are 
confidential and intended for the addressee(s) only.  If you have received this 
message in error or there are any problems, please notify the sender 
immediately.  The unauthorized use, disclosure, copying or alteration of this 
message is strictly forbidden.  Note that any views or opinions presented in 
this email are solely those of the author and do not necessarily represent 
those of Radan Computational Ltd.  The recipient(s) of this message should 
check it and any attached files for viruses: Radan Computational will accept no 
liability for any damage caused by any virus transmitted by this email.

Reply via email to