use File::Basename; my $path = "/path/to/file"; print dirname( $path ), $/;