Replacement of Perl script