in reply to Quoting arguments to system

You don't need to make it quoted. The "argv" of ls is identical on the two shell command invocations. The shell ignores the quotes, because there wasn't any whitespace in the filename word.

If you want to show two different shell lines, then hand the command to the shell, using a single-arg invocation for system:

for my $quote (q{}, q{"}) { $cmd = "ls -l ${quote}simple.pl${quote}"; warn $cmd; system $cmd;
However, I would not recommend doing this in production code. This is just a demo.

The real question I have is "what are you trying to do, and why do you care about the quotes?".

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
RE: Re: Quoting arguments to system
by princepawn (Parson) on Oct 21, 2000 at 02:27 UTC
    Well, one thing I was trying to do was be sure I could emulate anything I did from the shell with Perl's system command. Because the manpage did not shed any light on the distinction you just mentioned, I thought I would ask here.

    Secondarily, and more specific to my problem at hand, we have an age-old Perl script where the guy hand-fashioned the command-line interface. When you want to send a list of args to an option, you do so like this:

    perl5 old-crusty-program.pl -f"arg1 arg2 arg3"