#! perl -slw use strict; printf "%s", scalar ; my @points = map[ split ' ', $_ ], ; my @modified; my %xseen; push @modified, shift @points; $xseen{$modified[-1][0]} = undef; while ( @points ) { if ( $points[0][0] < $modified[-1][0] ) { if ( exists( $xseen{$points[0][0]} )) { shift @points; next; } else { pop @modified; } } elsif ( $points[0][0] eq $modified[-1][0] ) { pop @modified; } push @modified, shift @points; $xseen{$modified[-1][0]} = undef; } print join ' ', @$_ for @modified;