in reply to use of <STDOUT>

Use backticks $dirval = `pwd` or open(P, "pwd |").