unix.pm

来自「网页留言本,比一般的留言簿管用」· PM 代码 · 共 49 行

PM
49
字号
package URI::file::Unix;require URI::file::Base;@ISA=qw(URI::file::Base);use strict;use URI::Escape qw(uri_unescape);sub extract_path{    my($class, $path) = @_;    # tidy path    $path =~ s,//+,/,g;    $path =~ s,(/\.)+/,/,g;    $path = "./$path" if $path =~ m,^[^:/]+:,,; # look like "scheme:"    $path;}sub file{    my $class = shift;    my $uri = shift;    my @path;    my $auth = $uri->authority;    if (defined($auth)) {	if (lc($auth) ne "localhost" && $auth ne "") {	    $auth = uri_unescape($auth);	    unless ($class->is_this_host($auth)) {		push(@path, "", "", $auth);	    }	}    }    my @ps = $uri->path_segments;    shift @ps if @path;    push(@path, @ps);    for (@path) {	# Unix file/directory names are not allowed to contain '\0' or '/'	return if /\0/;	return if /\//;  # should we really?    }    join("/", @path);}1;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?