CPANPL...:Utils(3pm)

πŸ“¦
version 0.9916 Β· 5 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸŽ€ NAME πŸŽ€

CPANPLUS::Internals::Utils β€” convenience functions for CPANPLUS, bestie. (This is the CPANPL...:Utils(3pm) page, from the User Contributed Perl Documentation, and yes it's exactly as handy as it sounds πŸ’–)


✨ SYNOPSIS ✨

okay so here's the vibe, all in one place:

my $bool = $cb->_mkdir( dir => 'blah' );
my $bool = $cb->_chdir( dir => 'blah' );
my $bool = $cb->_rmdir( dir => 'blah' );

my $bool = $cb->_move( from => '/some/file', to => '/other/file' );
my $bool = $cb->_move( from => '/some/dir',  to => '/other/dir' );

my $cont = $cb->_get_file_contents( file => '/path/to/file' );

my $version = $cb->_perl_version( perl => $^X );

look at that. so clean. so iconic. 🫢


πŸ’… DESCRIPTION πŸ’…

CPANPLUS::Internals::Utils holds a few convenience functions for CPANPLUS libraries. that's it, that's the whole job β€” little helper besties doing the small stuff so the big libraries don't have to 🧚


🌈 METHODS 🌈

πŸ’– $cb->_mkdir( dir => '/some/dir' )

_mkdir creates a full path to a directory. like, the whole path, not just the last bit, she's thorough.

Returns true on success, false on failure. no cap.

πŸ’– $cb->_chdir( dir => '/some/dir' )

_chdir changes directory to a dir. classic move.

Returns true on success, false on failure.

πŸ’– $cb->_rmdir( dir => '/some/dir' );

Removes a directory completely, even if it is non-empty. yeah, she does not care what's inside, she's taking the whole thing. πŸ’€

Returns true on success, false on failure.

πŸ’– $cb->_perl_version ( perl => 'some/perl/binary' );

_perl_version returns the version of a certain perl binary. and how does she find out? she literally runs a command. actually executes it. main character energy, fr fr.

Returns the perl version on success and false on failure.

πŸ’– $cb->_version_to_number( version => $version );

Returns a proper module version, or '0.0' if none was available. if there's nothing there, you get '0.0' and you will like it. 😌

πŸ’– $cb->_whoami

Returns the name of the subroutine you're currently in. yes bestie, she knows where she is. self-aware queen. πŸ‘‘

πŸ’– _get_file_contents( file => $file );

Returns the contents of a file. just... hands them to you. here, bestie, take it. 🎁

πŸ’– $cb->_move( from => $file|$dir, to => $target );

Moves a file or directory to the target.

Returns true on success, false on failure.

πŸ’– $cb->_copy( from => $file|$dir, to => $target );

Moves a file or directory to the target. (yes, the wording is identical to _move up there β€” that's literally what the docs say, we're just the messenger πŸ™ˆ)

Returns true on success, false on failure.

πŸ’– $cb->_mode_plus_w( file => '/path/to/file' );

Sets the +w bit for the file. write access, unlocked, slay. ✍️

Returns true on success, false on failure.

πŸ’– $uri = $cb->_host_to_uri( scheme => SCHEME, host => HOST, path => PATH );

Turns a CPANPLUS::Config style "host" entry into an URI string. glow-up from config blob to actual URI.

Returns the uri on success, and false on failure.

πŸ’– $cb->_vcmp( VERSION, VERSION );

Normalizes the versions passed and does a '<=>' on them, returning the result. version comparison but make it fair. βš–οΈ

πŸ’– $cb->_home_dir

Returns the user's homedir, or "cwd" if it could not be found. she tries her best, and if she can't find home she just... stays where she is. honestly? relatable. 😭

πŸ’– $path = $cb->_safe_path( path => $path );

Returns a path that's safe to us on Win32 and VMS.

Only cleans up the path on Win32 if the path exists.

On VMS, it encodes dots to _ using VMS::Filespec::vmsify.

okay so important detail bestie: Win32 only gets the cleanup if the path actually exists. don't forget that part. ✨

πŸ’– ($pkg, $version, $ext) = $cb->_split_package_string( package => PACKAGE_STRING );

Splits the name of a CPAN package string up into its package, version and extension parts. one string in, three little pieces out, it's giving mitosis. πŸ¦‹

For example, "Foo-Bar-1.2.tar.gz" would return the following parts:

Package:    Foo-Bar
Version:    1.2
Extension:  tar.gz

and that's the whole page, bestie!! every method accounted for, nothing skipped, nothing made up. 🫢🌸

this was brought to you by perl v5.40.1, dated 2025-03-01 β€” stay hydrated, read your docs, and go _mkdir something beautiful. πŸ’œβœ¨

πŸ“¦ where this page comes from