I think the Join() is incorrect in the Print() udf. Try changing the join line to

$_=join($_,'\')