in reply to substring too short and I don't care

Replace
substr($_,279) =~ s/$regex/$substitute{$1}/g;
with
substr($_,279) =~ s/$regex/$substitute{$1}/g unless length < 279;
or with
{ no warnings; substr($_,279) =~ s/$regex/$substitute{$1}/g; }