++ed by:
30 non-PAUSE users
Author image Jeffrey Ryan Thalhammer
and 24 contributors


Pinto::Util - Static utility functions for Pinto


version 0.14


This is a private module for internal use only. There is nothing for you to see here (yet). All API documentation is purely for my own reference.




Throws a Pinto::Exception with the given message. If given a reference to a Pinto::Exception object, then it just throws it again.

debug( $message )

debug( sub {...} )

Writes the message on STDERR if the PINTO_DEBUG environment variable is true. If the argument is a subroutine, it will be invoked and its output will be written instead. Always returns true.

whine( $message )

Just calls warn(), but always appends the newline so that line numbers are suppressed.

author_dir( @base, $author )

Given the name of an $author, returns the directory where the distributions for that author belong (as a Path::Class::Dir). The optional @base can be a series of Path::Class:Dir or path parts (as strings). If @base is given, it will be prepended to the directory that is returned.

itis( $var, $class )

Asserts whether var is a blessed reference and is an instance of the $class.

parse_dist_path( $path )

Parses a path like the ones you would see in a full URI to a distribution in a CPAN repository, or the URI fragment you would see in a CPAN index. Returns the author and file name of the distribution. Subdirectories between the author name and the file name are discarded.

isa_perl( $path_or_uri )

Return true if $path_or_uri appears to point to a release of perl itself. This is based on some file naming patterns that I've seen in the wild. It may not be completely accurate.

mtime( $file )

Returns the last modification time (in epoch seconds) for the file. The argument is required and the file must exist or an exception will be thrown.

md5( $file )

Returns the MD-5 digest (as a hex string) for the $file. The argument is required and the file must exist on an exception will be thrown.

sha256( $file )

Returns the SHA-256 digest (as a hex string) for the $file. The argument is required and the file must exist on an exception will be thrown.

validate_property_name( $prop_name )

Throws an exception if the property name is invalid. Currently, property names must be alphanumeric plus any underscores or hyphens.

validate_stack_name( $stack_name )

Throws an exception if the stack name is invalid. Currently, stack names must be alphanumeric plus underscores or hyphens.


Returns the current time (in epoch seconds) unless the current time has been overridden by $Pinto::Globals::current_utc_time.


Returns the offset between current UTC time and the local time in seconds, unless overridden by $Pinto::Globals::current_time_offset. The current_time function is used to determine the current UTC time.


Returns the username of the current user unless it has been overridden by $Pinto::Globals::current_username. The username can be defined through a number of environment variables. Throws an exception if no username can be determined.


Returns the author id of the current user unless it has been overridden by $Pinto::Globals::current_author_id. The author id can be defined through environment variables. Otherwise it defaults to the upper-case form of the current_username. And since PAUSE only allows letters and numbers in the author id, then we remove all of those from the current_username too.


Returns true if the process is connected to an interactive terminal (i.e. a keyboard & screen) unless it has been overridden by $Pinto::Globals::is_interactive.


Performs interpolation on a literal string. The string should not include anything that looks like a variable. Only metacharacters (like \n) will be interpolated correctly.


Returns the string with all leading and trailing whitespace removed.


Returns all the characters in $string before the first newline. If there is no newline, returns the entire $string.


Returns all the characters in $string after the first newline. If there is no newline, returns an empty string.

truncate_text($string, $length, $elipses)

Truncates the $string and appends $elipses if the $string is longer than $length characters. $elipses defaults to '...' if not specified.


Returns the string forced to lower case and words separated by underscores. For example FooBar becomes foo_bar.

indent_text($string, $n)

Returns a copy of $string with each line indented by $n spaces. In other words, it puts 4n spaces immediately after each newline in $string. The original $string is not modified.

mksymlink($from => $to)

Creates a symlink between the two files. No checks are performed to see if either path is valid or already exists. Throws an exception if the operation fails or is not supported.


Returns true if $string is the name of a system property.


Returns a UUID as a string. Currently, the UUID is derived from random numbers.


Returns a reference to an array containing the names of the colors pinto can use. This can be influenced by setting the PINTO_PALETTE environment variable.


Returns true if the string is undefined, empty, or contains only whitespace.


Returns true if the string contains any non-whitespace characters.


Masks the parts the string that look like a password embedded in an http or https URI. For example, http://joe:secret@foo.com would return http://joe:*password*@foo.com

is_remote_repo {

Returns true if the argument looks like a URI to a remote repository


Jeffrey Ryan Thalhammer <jeff@stratopan.com>


This software is copyright (c) 2015 by Jeffrey Ryan Thalhammer.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.