in reply to Golf code in perl

”I am new to perl and somehow I wrote the code in perl."

I think it's disingenuous to claim you wrote this code. The idea behind such challenges which you've copied/paste here is that the participant exercise their skills.and try out new tricks. Since you claim to be new to perl I suggest your time would be better spent learning the basics, rather than keep asking people to improve someone else's answer (inbox spam isn't a wise course of action by the way), http://learn.perl.org, learn perl in 2 hours 30 minutes. Work through the tutorials section of this site. Ask specific questions (How do I post a question effectively?), rather than repeat "do it for me" type requests.