open FILE, "<", $ARGV[0] or die $!; while() { chomp(); while (/\G.+/g) { # iterate throug the line if (/([XYZA])([+-]?\d+\.\d+)/) { # if matches a coordinate my $coord = sprintf("<$1%.3f>", $2); # round the value, print "$coord"; # and print it } else { # trouble! print; # I'd like to print non-matching cases } print "\n"; # finish printing the line } }