Monday, May 24, 2010

Plzz tell me how to append a file in perl and adding information from another file (concatenation) of info?

The %26gt;%26gt; opens the file for appending.





open(LOGFILE, "%26gt;%26gt; /tmp/log") or die "Can't write /tmp/log: $!";





The "hello world\n" will be appended.


print LOGFILE "hello world\n";





if you want to read from another file, just open it, read each line and write it:


open(FH, "input.txt");


while (%26lt;FH%26gt;) { print LOGFILE $_; }


No comments:

Post a Comment