The following is a simple perl code to open a file and read line by line .

#!/usr/local/bin/perl -w

open("FILE","%filename");
my line;

while(defined($line=%FILE*))
{
print FILE $line;
}

close(FILE);

The following is a simple perl code to open a file and read line by line and write the content to another file .


#!/usr/local/bin/perl -w

open(FILE_READ,"%filename1");
open(FILE_WRITE,"%filename2");
my $line;
while(defined($line=%file_read*))
{
print FILE_WRITE $line;
}

close(FILE_READ);
close(FILE_WRITE);

Note: For the above 2 programs change % with <>.

Perl is case sensitive , so please be careful while writing the program .

Related Posts :



Bookmark and Share