in reply to Problems with <STDIN> in scalar context

You need to indicate how you are running your script, and some information about your environment, because the script works fine as it is, so you have a problem that is not related to the code you included here.

  • Comment on Re: Problems with <STDIN> in scalar context