in reply to Complaints from Warnings about uninitialized var

after your split to get $middle you could do

$middle ||= '';
or
$middle = '' unless defined $middle;