This might seem pedantic, but it appears that you are entering the directory name as a parameter on the command-line. This is placed into array @ARGV (hence the comment above).
You program is reading from the standard-input stream (which is the keyboard by default), without a prompt.