在 Perl 中,如何从文件中删除 ^M? [英] In Perl, how to remove ^M from a file?

查看:41
本文介绍了在 Perl 中,如何从文件中删除 ^M?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个将新字段附加到现有 CSV 的脚本,但是 ^M 字符出现在旧行的末尾,因此新字段最终位于新行而不是一样的.如何使用 Perl 从 CSV 文件中删除 ^M 字符?

I have a script that is appending new fields to an existing CSV, however ^M characters are appearing at the end of the old lines so the new fields end up on a new row instead of the same one. How do I remove ^M characters from a CSV file using Perl?

推荐答案

你发现你也可以这样做:

You found out you can also do this:

$line=~ tr/\015//d;

这篇关于在 Perl 中,如何从文件中删除 ^M?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆