in reply to how to escape round parentheses in a system call

To convert a string to a shell literal, you can use String::ShellQuote's shell_quote. (If you're building a Windows command, see Win32::ShellQuote.)

use String::ShellQuote qw( shell_quote ); my $cmd = shell_quote( "prog", $_->{Sub_URL}, "(?i)Podcast", @args ); system( $cmd );

But why invoke a shell at all?

my @cmd = ( "prog", $_->{Sub_URL}, "(?i)Podcast", @args ); system( { $cmd[0] } @cmd );

(Ignore afoken's disparagement of shell_quote. He thinks the fact that unix and Windows are different is a defect of the module.)

Replies are listed 'Best First'.
Re^2: how to escape round parentheses in a system call
by roho (Bishop) on Jun 12, 2023 at 05:12 UTC

    FYI - I liked your answer ikegami. Shell:Quote module looked to be very helpful, but it does not exist in CPAN. However, I did find the following modules:

    ShellQuote::Any - Escape strings for the shell on Linux, UNIX or MSWin32
    Win32::ShellQuote - Quote argument lists for Win32
    ShellQuote::Any::Tiny - Escape string for the Unix/Windows shell

    "It's not how hard you work, it's how much you get done."