align code with Perl 5 version