#To sort the records for (@records){ if ($_->{'severity'} eq "critical"){ #sort the array @records and assign line number @records = sort{ $a->{event_age} <=> $b->{event_age} } @records; for my $i (0 .. $#records) { $records[$i]->{line} = $i + 1; } #End# } } # To Restrict the row count to 12 to fit the screen my $max = 12; for (@records){ if ($_->{'line'} < $max){ #DoNothing } } #Set Visibility to "No" if records are more then 12 for (@records+1..$max){ push @records, { line => $_, severity => "", ticketnum => "", appname => "", appname => "", event_age => "" , visible => "No", appspectname => "" }; } print Dumper \@records;