CPANPL...:Fetch(3pm)
π CPANPLUS::Internals::Fetch β the internals for fetching files π
okay bestie, so this is CPANPLUS::Internals::Fetch, a page from the User Contributed Perl Documentation collection (the 3pm girlies know), and it's literally all about the behind-the-scenes machinery that goes and grabs your files. not the glamorous part, but it's the part that makes everything else work, so. main character energy fr fr. π
β¨ SYNOPSIS β¨
here's the vibe check, verbatim:
my $output = $cb->_fetch(
module => $modobj,
fetchdir => '/path/to/save/to',
verbose => BOOL,
force => BOOL,
);
$cb->_add_fail_host( host => 'foo.com' );
$cb->_host_ok( host => 'foo.com' );
that's it. that's the whole teaser. now let's get into it π¦
πΈ DESCRIPTION πΈ
CPANPLUS::Internals::Fetch fetches files from either ftp, http, file or rsync mirrors. yes, all four. she contains multitudes π
and the rough flow β the whole plot, condensed β is this:
$cb->_fetch
Delegate to File::Fetch;
so she does the thinking, and File::Fetch does the actual grabbing. delegation queen. π
π METHODS π
$path = _fetch( module => $modobj, [fetchdir => '/path/to/save/to', fetch_from => 'scheme://path/to/fetch/from', verbose => BOOL, force => BOOL, prefer_bin => BOOL, ttl => $seconds] )
so _fetch goes and fetches files based on whatever info is living inside a module object. you always need a module object β that part is non-negotiable, no cap. and if you want a fake module object for a one-off fetch, go look at CPANPLUS::Module::Fake. she's right there, ready to be your stand-in π«Ά
now the args, one by one:
fetchdirβ the place to save the file to. usually this info comes from your configuration, but you can override it expressly if you need to. your config, your rules, but also your call πfetch_fromβ lets you specify an URI to get this file from. if you don't specify one, your list of configured hosts will be probed to download the file from. so either you tell her exactly where to go, or she goes knocking on doors. either way, she's getting that file.forceβ forces a new download, even if the file already exists. yes bestie, even then. it's giving "I said what I said" π€verboseβ simply indicates whether or not to print extra messages. she can be chatty or she can be mysterious, your choice β¨prefer_binβ indicates whether you prefer the use of commandline programs over perl modules. defaults to your corresponding config setting.ttl(in seconds) β indicates how long a cached copy is valid for. if the fetch time of the local copy is within the ttl, the cached copy is returned. otherwise, the file is refetched. so like, if your snack is still fresh, you eat the snack. if it's expired, new snack. periodt π
and then, _fetch figures out β based on the host list β what scheme to use, and from there she delegates to File::Fetch to do the actual fetching. the way she just knows which scheme. iykyk π
Returns the path of the output file on success, false on failure. that's the receipt, bestie.
π¨ important side note: you can set a"blacklist"on certain methods in the config. simply add the identifying name of the method (ie,"lwp") to:
$conf->_set_fetch( blacklist => ['lwp'] );
and the "LWP" function will be skipped by File::Fetch. blocking someone without blocking them, iconic behavior π
_add_fail_host( host => $host_hashref )
mark a particular host as bad. π« this makes CPANPLUS::Internals::Fetch skip it in fetches until this cache is flushed. she's holding a grudge, but like, a productive one. it's on the list and it's staying on the list π
_host_ok( host => $host_hashref )
query the cache to see if this host is ok, or if it has been flagged as bad. basically a background check, but make it fetch-adjacent π΅οΈβοΈ
Returns true if the host is ok, false otherwise. simple as that, no notes.
and that's the whole page, bestie!! π
β¨ this was perl v5.40.1, dated 2025-03-01, and honestly? she ate. go fetch something. πππ¦
π¦ where this page comes from
- debian trixie: libcpanplus-perl 0.9916-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libcpanplus-perl 0.9916-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcpanplus-perl 0.9916-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms