Monday, July 11, 2011

Writing to a file perl

perl_fileout.pl:

open(FILE,">>hello_out.dat");
print FILE "hello howw are you";
print FILE "wonderful";
print FILE "awesome";
print FILE "great";
close(FILE);
G:\perl_programs>perl perl_fileout.pl
G:\perl_programs>


When you run this program hell_out.dat is created in the current directory  with the following content:

hello howw are youwonderfulawesomegreat

the following program for making lines come in a new line:
open(FILE,">>hello_out.dat");
print FILE "hello howw are you"."\n";
print FILE "wonderful"."\n";
print FILE "awesome"."\n";
print FILE "great"."\n";
close(FILE);

No comments:

Post a Comment