Perl Fix

See commits for in depth comments.

/cc @mmzyk