in reply to use of <STDOUT>

Don't use system, use open with a pipe (avoiding <STDOUT>):

#!/usr/bin/perl
use strict;

my $dir;
open(SYS, "pwd |");
while (<SYS>) {$dir=$_; last;}
chomp $dir; print $dir;

Incidentally, if you use my $pid = open(SYS, "pwd |") you get the process number of "pwd" in a variable.

I presume there is no need to close(SYS) but someone may know better.