use Cwd; print cwd(), "\n"; -e 'foo' or mkdir('foo', 0777) or die "Can't mkdir 'foo': $!\n"; open(FH, '>foo/bar') or warn "Can't open 'foo/bar': $!\n"; # creates a file named 'foo/bar' in cwd open(FH, '>foo:bar') or warn "Can't open 'foo:bar': $!\n"; # fails, unless you actually have a volume named 'foo' # in that case, creates a file named 'bar' on the volume 'foo' open(FH, '>:foo:bar') or warn "Can't open ':foo:bar': $!\n"; # creates a file named 'bar' in the directory 'foo' in the cwd