Acrux
view release on metacpan or search on metacpan
0.07 Tue 04 Nov 2025 16:21:16 MSK
* Acme::Crux: root, configfile, logfile, pidfile attributes are redesigned
Now each of the listed attributes does not depend on the application
execution context.
0.06 Wed 05 Mar 2025 14:12:11 MSK
* Disabled strf test
0.05 Wed 21 Aug 2024 19:07:48 MSK
* The definition of the IS_TTY constant has been changed
* Added the prompt util function
* Modified 11-strf.t
0.04 Fri 14 Jun 2024 19:25:44
* Added strf util function
0.03 Sun 18 Feb 2024 07:50:05 MSK
* Added new requiremets
* Documentation modified
* The root directory for the config only applies to default files
lib/Acrux/Util.pm view on Meta::CPAN
# [qw(foo bar baz qux)]
parse_words(q{foo "bar baz" qux});
# ['foo', 'bar baz', 'qux']
parse_words([
q{foo,bar},
q{"baz qux"},
]); # ['foo', 'bar', 'baz qux']
See also L</words> for simply parsing
=head2 prompt
my $value = prompt($message);
my $value = prompt($message, $default);
The C<prompt()> is an extremely simple function, based on the extremely simple prompt
offered by L<ExtUtils::MakeMaker>. In many cases this function just to prompt for input
This function displays the message as a prompt for input and returns the (chomped)
response from the user, or the default if the response was empty
If the program is not running interactively, the default will be used without prompting.
If no default is provided, an empty string will be used instead
See also: L<ExtUtils::MakeMaker/prompt>, L<IO::Prompt::Tiny>
=head2 randchars
$rand = randchars( $n ); # default chars collection: 0..9,'a'..'z','A'..'Z'
$rand = randchars( $n, \@collection ); # Defined chars collection
Returns random sequence of casual characters by the amount of n
For example:
lib/Acrux/Util.pm view on Meta::CPAN
/);
our @EXPORT_OK = (qw/
fbytes human2bytes humanize_duration humanize_number
fdt dtf tz_diff fdate fdatetime fduration
randchars
dformat strf trim truncstr indent words
touch eqtime slurp spew spurt
parse_expire parse_time_offset parse_words
os_type is_os_type
color load_class
prompt
/, @EXPORT);
use constant HUMAN_SUFFIXES => {
'B' => 0,
'K' => 10, 'KB' => 10, 'KIB' => 10,
'M' => 20, 'MB' => 20, 'MIB' => 20,
'G' => 30, 'GB' => 30, 'GIB' => 30,
'T' => 40, 'TB' => 40, 'TIB' => 40,
'P' => 50, 'PB' => 50, 'PIB' => 50,
'E' => 60, 'EB' => 60, 'EIB' => 60,
lib/Acrux/Util.pm view on Meta::CPAN
sub os_type {
my $os = shift // $^O;
return $OSTYPES{$os} || '';
}
sub is_os_type {
my $type = shift || return;
return os_type(shift) eq $type;
}
# Copied from ExtUtils::MakeMaker and IO::Prompt::Tiny
sub prompt {
my $msg = shift // '';
my $def = shift // '';
my $dispdef = length($def) ? "[$def] " : " ";
# Flush vars
local $|=1;
local $\;
# Prompt message
print length($msg) ? "$msg $dispdef" : "$dispdef";
( run in 1.146 second using v1.01-cache-2.11-cpan-6aa56a78535 )