my $dir = "/whatever"; my $file = $dir."/file"; die "cannot write to $dir : $!" unless -W $dir;