I made a couple of slight revisions (eliminate the "last" statement and fixed a boundary condition issue at index 0). This still produces the same output.
Appreciated your thanks. I leave "what is better" up to you.
#! perl -slw
use strict;
printf "%s", scalar <DATA>;
my @points = map[ split ' ', $_ ], <DATA>;
my $i=0;
while ($i < @points-2) #quit when there aren't 2 points left
{
my ($x1,$y1) = @{$points[$i]};
my ($x2,$y2) = @{$points[$i+1]};
if ( ($y2 - $y1 ) / ( $x2 - $x1 ) < 0 )
{
splice @points,$i,2; #remove both points
$i--; #backup a point to restart
$i=0 if $i<0; #boundary condition at index 0
}
else
{
$i++;
}
}
print join ' ', @$_ for @points;