I\'ve written some code in Perl which executes some bash command within its execution. My problem was when bash command attributes contained white space inside which failed
Use quotemeta:
my $arg1 = quotemeta('string to be escaped');
`echo $arg1`
Or \Q\E (which is exactly what quotemeta is);
my $arg1 = 'string to be escaped';
`echo \Q$arg1\E`
And also please note that using echo is a bad way to print arbitrary strings.
And do NOT place any quotes around parameters if you're using quotemeta.