I don't think this approach will work any better than what
the seeker posted. The problem is that the values being
assigned to "$DIR" all have the line-termination character(s)
attached (/[\r\n]+/), whereas this was not the case for
the original shell script. You either have to "chomp $DIR"
or else use the "opendir()" and "readdir()" calls, as
demonstrated by DDA below.