Bini -- -21.89753 -20.47853 -20.27835 -18.34952 -16.23454
Bini -- -16.89753 -14.47853 -13.27835 -12.34952 -11.23454
Bini -- -10.09014
You can take all numbers from every line, push them at the end of @entries, and always keep only last three.
my @entries;
while(my $line = ) {
next if $line !~ /Bini/;
push @entries, grep /\d/, split /\s+/,$line;
@entries = @entries[-3 .. -1] if @entries > 3;
}
print join "\n", @entries;
output
-12.34952
-11.23454
-10.09014