We receive files with metacharacters in the file names that are probably coming from a Windows environment. An example would be ORDERS'UNH.dat, I am using this command to replace the metacharacters with an underscore.
$file_name=~s/(\W)/_/g;
I have to replace the ' in this case with an _ because the service I am passing it to will not accept \'. My delimia is that I don't want to convert the dot(.). Does anyone know an easy way to do this without several lines of code? Such as this:
$file_name=~ s/\ /\\\ /g;
$file_name=~ s/\'/\\\'/g;
$file_name=~ s/\"/\\\"/g;
$file_name=~ s/\(/\\\(/g;
$file_name=~ s/\)/\\\)/g;
$file_name=~ s/\&/\\\&/g;
$file_name=~ s/\*/\\\*/g;
$file_name=~ s/\|/\\\|/g;
Thanks for you help!
Hilarie
$file_name=~s/(\W)/_/g;
I have to replace the ' in this case with an _ because the service I am passing it to will not accept \'. My delimia is that I don't want to convert the dot(.). Does anyone know an easy way to do this without several lines of code? Such as this:
$file_name=~ s/\ /\\\ /g;
$file_name=~ s/\'/\\\'/g;
$file_name=~ s/\"/\\\"/g;
$file_name=~ s/\(/\\\(/g;
$file_name=~ s/\)/\\\)/g;
$file_name=~ s/\&/\\\&/g;
$file_name=~ s/\*/\\\*/g;
$file_name=~ s/\|/\\\|/g;
Thanks for you help!
Hilarie