Dear Friend,
You can use the following coding also. You can get the first line in the array of first index, second line in the second index .......
Here the file2 contains the following content
dat
data1
Code:
use strict;
use warnings;
use Data::Dumper;
my $i=0;
my @array;
my ($var,$j);
open(FH,'<file2');
while($var=<FH>)
{
chomp($var);
$array[$i] =$var;
$i++;
}
for ($j=0; $j<$i;$j++)
{
print '$temp['.$j.']='.$array[$j]."\n";
}