in reply to issue with the global variable.

Can anyone help me understanding how that values are coming from the file to above print statement.....

It looks like you could use more comments in this area, but I can't get by the suspicion that you are trying to learn how to use Perl in order to do un-welcome things to other people's machines. I'm commenting mostly as a flag to others, who might be reading through the thread fairly quickly.