Aion-Format
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Aion/Format.pm view on Meta::CPAN
package Aion::Format;
use 5.22.0;
no strict; no warnings; no diagnostics;
use common::sense;
our $VERSION = "0.0.10";
require POSIX;
require Term::ANSIColor;
use Exporter qw/import/;
our @EXPORT = our @EXPORT_OK = grep {
*{$Aion::Format::{$_}}{CODE} && !/^(_|(NaN|import)\z)/n
} keys %Aion::Format::;
#@category ÐÑвод ÑÑÑÑкÑÑÑ
use DDP {
colored => 1,
class => {
expand => "all",
inherited => "all",
show_reftype => 1,
},
deparse => 1,
show_unicode => 1,
show_readonly => 1,
print_escapes => 1,
#show_refcount => 1,
#show_memsize => 1,
caller_info => 1,
output => 'stdout',
#unicode_charnames => 1,
};
#@category ÐовÑÑки
# ÐовÑÑка Ð´Ð»Ñ STDERR
sub trapperr(&) {
my $sub = shift;
local *STDERR;
open STDERR, '>:utf8', \my $f;
$sub->();
close STDERR;
$f
}
# ÐовÑÑка Ð´Ð»Ñ STDOUT
sub trappout(&) {
my $sub = shift;
local *STDOUT;
open STDOUT, '>:utf8', \my $f;
$sub->();
close STDOUT;
$f
}
#@category ЦвеÑ
# ÐолоÑизиÑÑÐµÑ ÑекÑÑ escape-поÑледоваÑелÑноÑÑÑми: coloring("#{BOLD RED}ya#{}100!#RESET"), а заÑем - заменÑÐµÑ ÑоÑÐ¼Ð°Ñ sprintf-ом
sub coloring(@) {
my $s = shift;
$s =~ s!#\{(?<x>[\w \t]*)\}|#(?<x>\w+)!
my $x = $+{x};
$x = "RESET" if $x ~~ [qw/r R/];
Term::ANSIColor::color($x)
!nge;
sprintf $s, @_
}
# ÐеÑаÑÐ°ÐµÑ Ð² STDOUT вÑвод coloring
sub printcolor(@) {
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.613 second using v1.00-cache-2.02-grep-82fe00e-cpan-72ae3ad1e6da )