APM: Question: How to access command line before its parsed into @ARGV

Wayne Walker wwalker at bybent.com
Thu Aug 25 07:21:27 PDT 2005


Upon reflection, and Tim's comment, maybe you are wanting to reuse the
quoted args in a system call later.

myprog "a compound arg, probably a Windows filename with spaces" 32 safe

if in my prog you do:

system ("other_prog " . join " ", @ARGV);

other_prog would be called via a shell call and would see 11 arguments:

sh -c other_progam compound arg, probably a Windows filename with spaces 32 safe

If instead you put this in my_prog:

system ("other_prog", @ARGV);

Then perl will call execvp("other_prog", (list of "other_prog" and the _3_ args in @ARGV)

so other_prog will think you ran this at the shell, essentially:

other_prog "a compound arg, probably a Windows filename with spaces" 32 safe                                                      
Wayne

On Wed, Aug 24, 2005 at 07:14:28PM -0700, Bill Raty wrote:
> I'm needing to write a perl program that receives command line
> arguments that may be double quoted.  
> 
>   # This won't work as quotes are removed
>   my $command_line = join ' ', @ARGV;
> 
> -Bill
> 
> -Bill
> Reintarnation: Coming back to life as a hillbilly
> 
> _______________________________________________
> Austin mailing list
> Austin at pm.org
> http://mail.pm.org/mailman/listinfo/austin

-- 

Wayne Walker

wwalker at bybent.com                    Do you use Linux?!
http://www.bybent.com                 Get Counted!  http://counter.li.org/
Perl - http://www.perl.org/           Perl User Groups - http://www.pm.org/
Jabber:  wwalker at jabber.gnumber.com   AIM:     lwwalkerbybent
IRC:     wwalker on freenode.net


More information about the Austin mailing list