Thursday, October 1, 2015

Perl Script to read a file

Write a Perl script to read a file.

Here below is the Perl Script to read a file.

#!c:\perl64\bin\perl.exe -w
use strict;
use warnings;

my $filePath = "F:\\Perl\\Perl\\testfile.txt";
open(FILE,"$filePath") or die "couldn't open the file, $!";
#Reading the Complete file (Slurping) and printing the content
while(<FILE>)
{
 print my $line = $_;
}
close(FILE);

No comments:

Post a Comment