Milan

#!/usr/bin/perl
use DcUtilities;
use autobox::Core;
use Modern::Perl;

my $cases= [];
my ($data, $a, $b, $c, $r, $t, $f, $l, @marr);
my $u= DcUtilities->new;

# This bit here produces 10,000 lines of data where each line
# looks like this:
#     erod.dngj.kmop.gawl
#     kgsm.cxjy.cktl.lvfa
#     ciqh.nojb.klad.bgxm
$t= $u->mark;
for $a (1 .. 100_000) {
  @marr= ();
  for $c (1 .. 4) {
    $data= '';
    for $b (1 .. 4) {$data.= chr(int(rand(ord('z') - ord('a'))) + ord('a'))}
    push @marr, $data}
  $cases->push(join('.', @marr))}

time_code("milan1", sub {($a, $b, $c)= split(/\./, shift)});
time_code(
  "milan2",
  sub {
    @marr= split(/\./, shift);
    $a= shift @marr;
    $c= pop @marr;
    $b= join('.', @marr);
    $r= join('/', $a, $b, $c)});
time_code("milan3", sub {($a, $b, $c)= split_name(shift)});
time_code("milan4", sub {($a, $b, $c)= shift =~ /^([^\.]*)\.(.*)\.([^\.]*)$/});
time_code(
  "donnie",
  sub {
    $f= index($_[0], '.');
    $l= rindex($_[0], '.');
    $a= substr($_[0], 0, $f);
    $b= substr($_[0], $f + 1, $l - $f - 1);
    $c= substr($_[0], $l + 1)});

sub split_name {
  my ($a, $b, $c) = shift =~ /^([^\.]*)\.(.*)\.([^\.]*)$/;
  ($a, $b, $c);
}

sub time_code {
  my ($id, $code)= @_;
  say "$id: ", $u->time_code(
    sub {foreach my $data ($cases->flatten) {$code->($data)}}), "ms";
}