in reply to Efficient split for alpha numeric pairs in a row

Here's another, slightly different approach. It tries to factor regex elements, and to build an extraction regex (rather than a split pattern of some kind) based on a mapping of all valid commands to their possible values. I make some assumptions:

Note that the command sequence is validated before commands are extracted (the undefined  'C' command in one of the example sequences causes an abort). Also note that I use the  (?|pattern) extension of Perl 5.10+ (see Extended Patterns in perlre); if you need to avoid this construct, I can provide an alternative.
c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my $integer = qr{ (?<! \d) \d+ (?! \d) }xms; my $real = qr{ -? $integer [.] $integer }xms; ;; my %cmds = ( N => $integer, G => $integer, H => $integer, M => $integer, X => $real, Y => $real, I => $real, J => $real, ); ;; my ($rx_cmd) = map qr{ (?| $_) }xms, join q{ | }, map qq{($_) ($cmds{$_})}, keys %cmds ; ;; for my $s (qw( N260G02X142.05Y649.62I77.33J58.34H2M25 N265M20 N270G45 N290G03X324.39Y638.4I-69.58J67.4H2M25 N275G01X304.78Y608.8C45.91M25 N280M20 )) { print qq{seq: '$s'}; die qq{bad: '$s'} unless $s =~ m{ \A $rx_cmd+ \z }xms; my %parts = $s =~ m{ $rx_cmd }xmsg; dd \%parts; } " seq: 'N260G02X142.05Y649.62I77.33J58.34H2M25' { G => "02", H => 2, I => 77.33, J => 58.34, M => 25, N => 260, X => 1 +42.05, Y => 649.62 } seq: 'N265M20' { M => 20, N => 265 } seq: 'N270G45' { G => 45, N => 270 } seq: 'N290G03X324.39Y638.4I-69.58J67.4H2M25' { G => "03", H => 2, I => -69.58, J => 67.4, M => 25, N => 290, X => 3 +24.39, Y => 638.4 } seq: 'N275G01X304.78Y608.8C45.91M25' bad: 'N275G01X304.78Y608.8C45.91M25' at -e line 1.


Give a man a fish:  <%-(-(-(-<