in reply to My script is working fine on linux but it's not working on the Windows
Welcome to the Monastery, please read How do I post a question effectively?. You've posted unformated code (post formatting advice is displayed) and not mentioned what happens when you run it, or provided any input data.
No use strict; use warnings;? See Use strict and warnings and Use strict warnings and diagnostics.
In Section
Seekers of Perl Wisdom