假设我有:
my $a = "http://site.com";
my $part = "index.html";
my $full = join($a,$part);
print $full;
>> http://site.com/index.html
Run Code Online (Sandbox Code Playgroud)
join为了让我的代码段工作,我必须使用什么?
编辑:我正在寻找更通用的东西.如果a以斜线结尾并以一个part开头怎么办?我敢肯定,在某些模块中,有人会覆盖这个.
Eth*_*her 10
我相信你要找的是URI :: Split,例如:
use URI::Split qw(uri_join);
$uri = uri_join('http', 'site.com', 'index.html')
Run Code Online (Sandbox Code Playgroud)