I think the String::ShellQute module will do what
you need:
String::ShellQuote - quote strings for passing through the
shell. This module contains some functions which
are useful for
quoting strings which are
going to pass through the shell
or a shell-like object.