So I'm pretty new to Perl, only been learning it for 1 week. I'm trying to read only a specific range of lines into an array. If I print $_ inside the if statement, it list exactly what i want stored into my array. But storing $_ into my array and then print @array outside the while shows nothing. I'm not sure what I should do. Reason why I'm trying to store it into an array is too get certain information from the columns, therefore needing an array to do so. Thanks for your help. Its probably really simple for you guys
use strict;
use warnings;
my $filename = 'info.text';
open my $info, $filename or die "Could not open $filename: $!";
my $first_line = 2;
my $last_line = 15;
open(FILE, $filename) or die "Could not read from $filename, program halting.";
my $count = 1;
my @lines;
while(<FILE>){
if($count > $last_line){
close FILE;
exit;
}
if($count >= $first_line){
#print $_;
push @lines, $_;
}
$count++;
}
print @lines;