Reading each line of a file in perl script

HI
I need to read each line (test.txt) and store it in a array (@test)
How to do it in perl.

Suppose i have a file test.txt. I have to read each line of the test.txt file and store it in a array @test. How to do it in perl.

Regards
Harikrishna

Check if this helps...

TEST = "test.txt";
open(TEST) or die("Could not open log file.");
foreach $line (<TEST>) {
    chomp($line);              # remove the newline from $line.
    # do line-by-line processing.
}

open (F, "test.txt") || die "Could not open test.txt: $!\n";
@test = <F>;
close F;

Perhaps you should read one of the many excellent Perl tutorials on the net rather than rely entirely on trial and error, though.

Thanks alot era.... :slight_smile: