gpt4 book ai didi

Perl File::Fetch 失败,因为 URL 没有文件部分

转载 作者:行者123 更新时间:2023-12-04 20:49:38 24 4
gpt4 key购买 nike

我正在运行一个从数据库中提取 URL 并执行 file::fetch() 的脚本。据我了解, file::fetch() 仅在 URL 中确实有要下载的文件时才有效。

但是,在我的数据库中,偶尔会出现没有要获取文件的 URL。那么,是否有任何模块可以用来检查我正在尝试执行 file::fetch() 的 URL 中是否存在文件?

我的脚本中有一行

my $uri_handle = File::Fetch->new(uri => $url);

$url 可能类似于 http://asiaone.com没有要实际获取的文件。

我得到这个错误,我拼命试图避免,因为还有其他 URL 主要包含要获取的文件。
Use of uninitialized value $path in pattern match (m//) at C:/Perl/lib/File/Spec/Unix.pm line 267.
Use of uninitialized value in string eq at C:/Perl/lib/File/Fetch.pm line 395.
Hostname required when fetching from 'http' at C:\test\multihashtest2.pl line 100 thread 2

如何格式化我的正则表达式以检查文件,或者是否有我可以使用的模块来促进这一点?

合法的 URL 如下所示
http://the.earth.li/~sgtatham/putty/latest/x86/puttytel.exe

最佳答案

来自 manual of File::Fetch有这个标志,$File::Fetch::WARN , 您可以设置为 false为了消除错误:

This variable controls whether errors encountered internally by File::Fetch should be carp'd or not.

Set to false to silence warnings. Inspect the output of the error() method manually to see what went wrong.

Defaults to true.

关于Perl File::Fetch 失败,因为 URL 没有文件部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12296489/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com