updated perl script