#!/usr/bin/perl -w use strict; while (<>) { my @coords = qw(0 0 0); chomp; my $l = $_; for (;;) { print join '', @coords, ','; last unless $l =~ s/^.//; $_ = $&; my $delta = s/[A-Z]/lc $&/e ? +1 : -1; my $i = /x/ ? 0 : /y/ ? 1 : /z/ ? 2 : die "$_ ?"; $coords[$i] += $delta; } print "\n"; } STDOUT->error and die $!;