Aion-Format
view release on metacpan or search on metacpan
lib/Aion/Format.pm view on Meta::CPAN
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;
lib/Aion/Format.pm view on Meta::CPAN
$s //= "N";
$s =~ s/ \z//;
$s
}
# ÐÑполÑÐ·Ð¾Ð²Ð°Ð½Ñ ÑÐ¸Ð¼Ð²Ð¾Ð»Ñ Ð¸Ð· кодиÑовки cp1251, ÑÑо нÑжно Ð´Ð»Ñ ÐºÐ¾ÑÑекÑной запиÑи в ÑаблиÑÑ
our $CIF = join "", "0".."9", "A".."Z", "a".."z", "_-", # 64 Ñимвола Ð´Ð»Ñ 64-ÑиÑной ÑиÑÑÐµÐ¼Ñ ÑÑиÑлениÑ
(map chr, ord "Ð" .. ord "Я"), "ÐÐÐÐÐÐÐÐÐÐÒÐÐÐÐ
",
(map chr, ord "а" .. ord "Ñ"), "ÑÑÑÑÑÑÑÑÑÑÒÑÑÑÑ",
"âââ¦â â¡â¬â°â¹âââââ¢âââ¢âºÂ¤Â¦Â§Â©Â«Â¬Â®°±µ¶·â»", do { no utf8; chr 0xa0 }, # небÑквеннÑе ÑÐ¸Ð¼Ð²Ð¾Ð»Ñ Ð¸Ð· cp1251
"!\"#\$%&'()*+,./:;<=>?\@[\\]^`{|}~", # ÑÐ¸Ð¼Ð²Ð¾Ð»Ñ Ð¿ÑнкÑÑаÑии ASCII
" ", # пÑобел
(map chr, 0 .. 0x1F, 0x7F), # ÑпÑавлÑÑÑие ÑÐ¸Ð¼Ð²Ð¾Ð»Ñ ASCII
# Ñимвол 152 (0x98) в cp1251 оÑÑÑÑÑÑвÑеÑ.
;
# ÐеÑÐµÐ²Ð¾Ð´Ð¸Ñ Ð½Ð°ÑÑÑалÑное ÑиÑло в заданнÑÑ ÑиÑÑÐµÐ¼Ñ ÑÑиÑлениÑ
sub to_radix($;$) {
use bigint;
my ($n, $radix) = @_;
$radix //= 64;
t/aion/format.t view on Meta::CPAN
use common::sense; use open qw/:std :utf8/; use Test::More 0.98; sub _mkpath_ { my ($p) = @_; length($`) && !-e $`? mkdir($`, 0755) || die "mkdir $`: $!": () while $p =~ m!/!g; $p } BEGIN { use Scalar::Util qw//; use Carp qw//; $SIG{__DIE__} = sub { ...
#
# Aion::Format - Perl extension for formatting numbers, colorizing output and so on
#
# # VERSION
#
# 0.0.9
#
# # SYNOPSIS
#
subtest 'SYNOPSIS' => sub {
t/aion/format/html.t view on Meta::CPAN
use common::sense; use open qw/:std :utf8/; use Test::More 0.98; sub _mkpath_ { my ($p) = @_; length($`) && !-e $`? mkdir($`, 0755) || die "mkdir $`: $!": () while $p =~ m!/!g; $p } BEGIN { use Scalar::Util qw//; use Carp qw//; $SIG{__DIE__} = sub { ...
#
# Aion::Format::Html - Perl extension for formatting HTML
#
# # SYNOPSIS
#
subtest 'SYNOPSIS' => sub {
use Aion::Format::Html;
::is scalar do {from_html "<b>!</b>"}, "!", 'from_html "<b>!</b>" # => !';
::is scalar do {to_html "<a>"}, "<a>", 'to_html "<a>" # => <a>';
t/aion/format/json.t view on Meta::CPAN
use common::sense; use open qw/:std :utf8/; use Test::More 0.98; sub _mkpath_ { my ($p) = @_; length($`) && !-e $`? mkdir($`, 0755) || die "mkdir $`: $!": () while $p =~ m!/!g; $p } BEGIN { use Scalar::Util qw//; use Carp qw//; $SIG{__DIE__} = sub { ...
#
# Aion::Format::Json - Perl extension for formatting JSON
#
# # SYNOPSIS
#
subtest 'SYNOPSIS' => sub {
use Aion::Format::Json;
::is scalar do {to_json {a => 10}}, "{\n \"a\": 10\n}\n", 'to_json {a => 10} # => {\n "a": 10\n}\n';
::is_deeply scalar do {from_json '[1, "5"]'}, scalar do {[1, "5"]}, 'from_json \'[1, "5"]\' # --> [1, "5"]';
t/aion/format/url.t view on Meta::CPAN
use common::sense; use open qw/:std :utf8/; use Test::More 0.98; sub _mkpath_ { my ($p) = @_; length($`) && !-e $`? mkdir($`, 0755) || die "mkdir $`: $!": () while $p =~ m!/!g; $p } BEGIN { use Scalar::Util qw//; use Carp qw//; $SIG{__DIE__} = sub { ...
#
# Aion::Format::Url - the utitlities for encode and decode the urls
#
# # SYNOPSIS
#
subtest 'SYNOPSIS' => sub {
use Aion::Format::Url;
::is scalar do {to_url_params {a => 1, b => [[1,2],3,{x=>10}]}}, "a&b[][]&b[][]=2&b[]=3&b[][x]=10", 'to_url_params {a => 1, b => [[1,2],3,{x=>10}]} # => a&b[][]&b[][]=2&b[]=3&b[][x]=10';
( run in 1.304 second using v1.01-cache-2.11-cpan-49f99fa48dc )