Acrux
view release on metacpan or search on metacpan
lib/Acrux/Util.pm view on Meta::CPAN
For more features please use L<Date::Format>, L<DateTime> and L<POSIX/strftime>
=head2 fduration
print fduration( 123 );
Returns formatted duration value
=head2 humanize_duration
print humanize_duration ( 123 );
Turns duration value into a simplified human readable format
=head2 humanize_number
print humanize_number( $number, $sep );
Placement of separators discharges among digits.
For example 1`234`567 if $sep is char "`" (default)
=head2 human2bytes
my $bytes = human2bytes("100 kB");
Converts a human readable byte count into the pure number of bytes without any suffix
See also L<Mojo::Util/humanize_bytes>
=head2 indent
my $indented = indent($str, 4, ' ');
my $indented = indent($str, 1, "\t");
Indent multi-line string
# " foo\n bar\n baz\n"
print indent("foo\nbar\nbaz\n", 2);
You can use number of indent-chars and indent-symbol manuality:
# "> foo\n> bar\n> baz\n"
my $data = indent("foo\nbar\nbaz\n", 1, '> ');
See also L<Mojo::Util/unindent> to unindent multi-line strings
=head2 is_os_type
$is_windows = is_os_type('Windows');
$is_unix = is_os_type('Unix', 'dragonfly');
Given an OS type and OS name, returns true or false if the OS name is of the given type.
As with os_type, it will use the current operating system as a default
if no OS name is provided
Original this function see in L<Perl::OSType/is_os_type>
=head2 load_class
my $error = load_class('Foo::Bar');
Loads a class and returns a false value if loading was successful,
a true value if the class was not found or loading failed.
=head2 os_type
$os_type = os_type(); # Unix
$os_type = os_type('MSWin32'); # Windows
Returns a single, generic OS type for a given operating system name.
With no arguments, returns the OS type for the current value of $^O.
If the operating system is not recognized, the function will return the empty string.
Original this function see in L<Perl::OSType/os_type>
=head2 parse_expire
print parse_expire("+1d"); # 86400
print parse_expire("-1d"); # -86400
Returns offset of expires time (in secs).
Original this function is the part of CGI::Util::expire_calc!
This internal routine creates an expires time exactly some number of hours from the current time.
It incorporates modifications from Mark Fisher.
format for time can be in any of the forms:
now -- expire immediately
+180s -- in 180 seconds
+2m -- in 2 minutes
+12h -- in 12 hours
+1d -- in 1 day
+3M -- in 3 months
+2y -- in 2 years
-3m -- 3 minutes ago(!)
If you don't supply one of these forms, we assume you are specifying the date yourself
=head2 parse_time_offset
my $off = parse_time_offset("1h2m24s"); # 4344
my $off = parse_time_offset("1h 2m 24s"); # 4344
Returns offset of time (in secs)
=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
( run in 1.625 second using v1.01-cache-2.11-cpan-39bf76dae61 )