So you need to create a menu of the files in the current directory with the option to change directory to any sub-directory in the current directory or go up a level and the possibility of selecting a file in the current directory.
Something like Norton commander of old? or Midnight commander (mc) on Linux?
Break your problem into manageable bits.
- Write a menu function which takes an array, displays the contents with an identifier and returns the value associated with the identifier the user chooses
- Use readdir on the current directory to call the menu sub above with the contents of the curent directory
- If the returned value is a directory cd to it and repeat the process
- until the returned value is a file, in which case select it for processing.
- Process file.
Each of the steps above is straightforward, try coding them up and, if you have a problem come back to us with your code, the inputs and the errors you are seeing.
print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."