Removing CRLF (0D 0A) from string in Perl

后端 未结 3 768
梦如初夏
梦如初夏 2021-01-18 00:11

I\'ve got a Perl script which consumes an XML file on Linux and occasionally there are CRLF (Hex 0D0A, Dos new lines) in some of the node values which.

The system w

3条回答
  •  旧巷少年郎
    2021-01-18 00:55

    $output =~ tr/\x{d}\x{a}//d;
    

    These are both whitespace characters, so if the terminators are always at the end, you can right-trim with

    $output =~ s/\s+\z//;
    

提交回复
热议问题