Tuesday, November 8, 2011

Writing to File using Perl

sriram@ubuntu:~/perl$ cat file1.txt (File toWrite to)
The Rock|Cheer|Rock Bottom
Triple H|Boo|Pedigree
Stone Cold|Cheer|Stone Cold Stunner
sriram@ubuntu:~/perl$

sriram@ubuntu:~/perl$ cat write.pl(Perl Script to Write)
#!/usr/bin/perl
open (TEST, '>>file1.txt')
print TEST "Sriram Test \n";
close(TEST);

Result :

sriram@ubuntu:~/perl$ cat file1.txt (Result)
The Rock|Cheer|Rock Bottom
Triple H|Boo|Pedigree
Stone Cold|Cheer|Stone Cold Stunner
Sriram Test
sriram@ubuntu:~/perl$









No comments:

Post a Comment