use URI::Escape; my $safe_field = uri_escape($field); ## now you can put $safe_field in the db ## without worry about CR/LF a ## restore it: $field = uri_unescape($safe_field);