我如何...如何使用Perl将字符串附加到每一行? [英] How do i...how to append the string to each line using Perl?

查看:78
本文介绍了我如何...如何使用Perl将字符串附加到每一行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用perl将字符串附加到文本文件中的每一行?



输入文件:t.txt

使用严格

使用警告



产生的输出:



使用严格

使用警告

aString



预期输出:



使用严格的aString

使用警告aString



我尝试过:



How can i append the string to each line inside the text file using perl?

Input file:t.txt
use strict
use warnings

output generated:

use strict
use warnings
aString

Expected output:

use strict aString
use warnings aString

What I have tried:

<pre> #!/usr/local/bin/perl
   open OUT,">>","t.txt" or die "error";
   #chomp(OUT);
   print OUT "aString";
   close OUT;

推荐答案

Google是您的朋友: Perl如何追加每行的字符串 - Google [ ^ ]
Google is your Friend: Perl how to append the string to each line - Google[^]


这篇关于我如何...如何使用Perl将字符串附加到每一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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