in reply to weird error when using substring function
sub introduces a subroutine. Some earlier versions of perl would (unintentionally) abort on bad syntax like you have there, but it should be fixed in current versions.