for (split(/:/, $$pattern)) { $_ = 'S0' . $_ unless /^S/; $_ .= 'S0' unless /S\d+$/; print STDERR "pattern: $_\n"; my @pieces = split(/[SF](\d+)/, $_); foreach my $count (0..$#pieces) { print STDERR "$count -> [$pieces[$count]] "; } print STDERR "\n"; } #### pattern: S51F11S0 0 -> [] 1 -> [51] 2 -> [] 3 -> [11] 4 -> [] 5 -> [0] #### pattern: S51F11S0 0 -> [51] 1 -> [11] 2 -> [0] #### tr/ //d; $camel .= $_;