Does it make sense to use shell_qoute from String::ShellQuote when I pass the arguments to system this way?
#!/usr/bin/env perl
use warnings;
use 5.012;
use String::ShellQuote qw(shell_quote);
my $file = shift;
my $argument = shift;
$file = shell_quote $file;
$argument = shell_quote $argument;
system( 'some_command', '--verbose', '-o', $file, $argument );
No it doesn’t. If you invoke
systemasthen it doesn’t invoke the shell. Shell meta-characters have no special meaning. So you must not quote your arguments, or else it gives the wrong results.
One needs to quote if
systemis invoked aswhere SCALAR might be something like
ls file name with spacesand the argument tolsis a single file name that has spaces.