princepawn has asked for the wisdom of the Perl Monks concerning the following question:
ls -l simple.pl
OR
ls -l "simple.pl"
The only difference being that I decided to quote the argument to ls.
Now, emulating my first shell command with the Perl system cmd is straightforward:
#!/usr/local/bin/perl5 use strict; my $file = 'simple.pl'; # the program being run! my @syscmd = ('ls' , '-l', $file); warn "@syscmd"; system @syscmd;
However, when attempting to emulate the second shell command Perl does something to preserve the quotes and make it a literal filename and thus the file "simple.pl" is not found.
So, the question becomes how does one emulate the second shell command that I issued from the shell using Perl's system command?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Quoting arguments to system
by merlyn (Sage) on Oct 21, 2000 at 02:12 UTC | |
by princepawn (Parson) on Oct 21, 2000 at 02:27 UTC | |
by merlyn (Sage) on Oct 21, 2000 at 09:54 UTC | |
|
Re: Quoting arguments to system
by clemburg (Curate) on Oct 21, 2000 at 21:37 UTC | |
|
Re: Quoting arguments to system
by Fastolfe (Vicar) on Oct 24, 2000 at 19:02 UTC |