I have written following perl script but problem is its always going in else part and reporting not a file. …