use strict;
my $line; #Store line currently being read
my $count=$ARGV[1]; # How many lines to read as passed from command line
my @last; #Array to store last count lines
my $index; #Index of the line being stored
#Open the file to read as supplied from command line
open (FILE,$ARGV[0]);
while ($line=<FILE>)
{
$index=$.%$count; # would help me in filter just $count records of the file
$last[$index]=$line; #store this value
}
close (FILE);
#Output the stored lines
for (my $i=$index+1;$i<$count;$i++)
{
print ("$last[$i]");
}
for (my $i=$0;$i<=$index;$i++)
{
print ("$last[$i]");
}