If $in_file is undef then <> (which uses the ARGV filehandle) will read from standard-input (STDIN). I suspect that your script is not hanging, but trying to read from the keyboard. To prove this, when it hangs type a few characters, then <CTRL>+D assuming UNIX/Linux (<CTRL>+Z<RETURN> on Windows). If the program unblocks checkout the file name in $in_file - there probably isn't one.