-2
A
回答
2
这应该工作,
#!/usr/bin/perl
# File: convert.pl
no utf8; # its not required
while (<>) {
s/(\xa3)/pound/g;
print;
}
因为£
在我的hexdump上显示为0xA3
。
但是,这样会
#!/usr/bin/perl
while (<>) {
s/£/pound/g;
print;
}
只是说
chmod a+x convert.pl
convert.pl yourfile.html > newfile.html
4
你很可能忘了:
use utf8;
试试下面的程序:
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
while (<DATA>) {
s/£/£/g;
print
}
__END__
This is sample text with lots of £££!
50£ is better than 0£.
如果你想从一个名为input
文件的读取和写入名为output
文件:
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
open my $input, '<', 'input' or die $!;
open my $output, '>', 'output' or die $!;
binmode $input, ':utf8';
while (<$input>) {
s/£/£/g;
print $output $_;
}
0
perl -i.bak -ne 's/£/£/g; print $_' file
相关问题
- 1. 如何在Vim中的文件夹中替换所有文件?
- 2. 如何在Perl替换之前替换匹配之前的所有文本?
- 3. 如何用Perl替换文件中的特定IP?
- 4. 如何用Perl替换文件中间的行?
- 5. 如何用Perl替换文件中的完整IP地址?
- 6. 如何用Perl中的bfjpv替换aeiou?
- 7. 替换所有文件夹中
- 8. 如何使用fix_mysql.inc.php文件替换Mysqli的所有MySql函数
- 9. 如何在文件夹中的所有文件中执行文本替换?
- 10. perl搜索和替换目录中的所有文件的脚本
- 11. 替换Windows中所有子文件夹中的所有文件名#
- 12. 如何用scala中的文字\ d替换所有数字?
- 13. 如何用一个字符替换文本文件中的所有空格?
- 14. ruby equivalent perl命令用于替换文件中的换行符?
- 15. 如何使用Perl列出目录中的所有文件?
- 16. 如何用Perl中的另一组替换文件中的一组单词?
- 17. 如何在一堆文本文件中用''替换所有'0xa0'字符?
- 18. 替换项目中所有java文件中的文本
- 19. 如何替换所有“?”使用javascript
- 20. 如何替换Mongo中所有文档中的字符串
- 21. 如何读取文件夹中的所有文件并使用Groovy替换文件中的模式
- 22. 用unix命令替换所有文件中的ruby代码
- 23. HTMLPurifier转换£回£
- 24. 如何替换我的manifest.json中的文件名使用rev-replace替换文件
- 25. 如何找出在Perl替换中被替换的内容?
- 26. 如何替换使用PHP ereg_replace替换所有特定字符?
- 27. 替换一组文件中的所有文本
- 28. Python:如何用所有文件,文件夹和子文件夹的名称中的下划线替换空格?
- 29. 如何用文本行上的空格替换所有星号(*)
- 30. 如何替换对UIWebView有用的html文件中的变量?
显示你尝试过什么,没有工作,使人们可以看到什么地方出了错,并帮助你? – ysth 2009-07-06 08:37:39
你一直在评论“问题是什么”,但没有人会告诉你,因为你没有说你做了什么。你想在Vim做这个吗?如果是这样,_how_?你想用Perl来做这个吗?如果是这样,_how_? – Telemachus 2009-07-06 10:34:44
对不起,它之前,我插入其他评论并删除它。现在问题得到解决 – joe 2009-07-06 10:37:08