One way is to treat the return values as a list and index into it:
$dir = (getpwnam($user))[7];
($dev, $ino, undef, undef, $uid, $gid) = stat($file);