this
    is just
    an example.
让我们假设上面是out.txt。我想读取out.txt并写入同一个文件。
    <Hi >
    <this>
    <is just>
    <an example.>
修改out.txt。我想在某些行的开头和结尾添加标签。由于我将多次读取该文件,因此我无法每次都将其写入不同的文件。
编辑 1
我尝试使用"+<",但它给出的输出如下:
Hi
this
is just
an example.
<Hi >
<this>
<is just>
<an example.>
 **out.txt**
编辑 2 代码供参考:
open(my $fh, "+<", "out.txt");# or die "cannot open < C:\Users\daanishs\workspace\CCoverage\out.txt: $!";
     while(<$fh>)
     {
        $s1 = "<";
        $s2 = $_;
        $s3 = ">";
        $str = $s1 . $s2 . $s3;
        print $fh "$str";
     }