sub localmirrors { my @mlist; # 定义存储本地镜像列表的数组 # 读取本地镜像列表文件 open LM, '$scriptdir/localmirrors' and do { while () { chomp $; push @mlist, $ if $; } close LM; }; # 读取配置文件中的本地镜像列表 open CONFIG, '<' . $ENV{'TOPDIR'} . '/.config' and do { while () { # 匹配本地镜像列表配置项 /^CONFIG_LOCALMIRROR='(.+)'/ and do { chomp $; # 将配置项中的本地镜像列表转换为数组并添加到 @mlist 中 my @local_mirrors = split(/;/, $1); push @mlist, @local_mirrors; }; } close CONFIG; }; # 返回本地镜像列表数组 return @mlist; }

Perl 获取本地镜像列表的函数 localmirrors