>perl -MShellQuote::Any::Tiny=shell_quote -E "system $^X, '-E', 'say for @ARGV', 1, shell_quote(qq(\x5c\x5c \x5c)), 2" 1 \\\ \ 2 #### perl -E "system $^X, '-E', 'say for @ARGV', qq(\x22abc\x22 d e)" perl -E "system $^X, '-E', 'say for @ARGV', qq(a\x5c\x5c\x5cb d\x22e f\x22g h)" perl -E "system $^X, '-E', 'say for @ARGV', qq(a\x5c\x5c\x5c\x22b c d)" perl -E "system $^X, '-E', 'say for @ARGV', qq(a\x5c\x5c\x5c\x5c\x22b c\x22 d e)" #### $arg =~ s/(\\(?!.*\\)|\\(?=\\)|")/\\$1/g; #### $arg =~ s/\\(?=\\*(?:"|$))/\\\\/g; $arg =~ s/"/\\"/g; #### perl -MShellQuote::Any::Tiny=shell_quote -E "system $^X, '-E', 'say for @ARGV', map {shell_quote $_} qw(abc d e)" perl -MShellQuote::Any::Tiny=shell_quote -E "system $^X, '-E', 'say for @ARGV', map {shell_quote $_} qq(a\x5c\x5c\x5cb), 'de fg', 'h'" perl -MShellQuote::Any::Tiny=shell_quote -E "system $^X, '-E', 'say for @ARGV', map {shell_quote $_} qq(a\x5c\x22b), 'c', 'd'" perl -MShellQuote::Any::Tiny=shell_quote -E "system $^X, '-E', 'say for @ARGV', map {shell_quote $_} qq(a\x5c\x5cb c), 'd', 'e'"