App-finddo
view release on metacpan or search on metacpan
script/finddo view on Meta::CPAN
# my $tff = $resmeta->{'table.fields'} or last;
# my $tfu = $resmeta->{'table.field_units'} or last;
# for my $i (0..$#columns) {
# my $field_idx = $field_idxs[$i];
# next unless $field_idx >= 0;
# next unless defined $tfu->[$field_idx];
# $data->[0][$i] .= " ($tfu->[$field_idx])";
# }
# }
#
# {
# my $tff = $resmeta->{'table.fields'} or last;
# my $tffmt = $resmeta->{'table.field_formats'} or last;
#
# my (@fmt_names, @fmt_opts);
# for my $i (0..$#columns) {
# my $field_idx = $field_idxs[$i];
# next unless $field_idx >= 0;
# next unless defined $tffmt->[$field_idx];
# if (ref($tffmt->[$field_idx]) eq 'ARRAY') {
# $fmt_names[$i] = $tffmt->[$field_idx][0];
# $fmt_opts [$i] = $tffmt->[$field_idx][1] // {};
# } else {
# $fmt_names[$i] = $tffmt->[$field_idx];
# $fmt_opts [$i] = {};
# }
# }
#
# my $nf;
#
# for my $i (0..$#{$data}) {
# next if $i==0 && $header_row;
# my $row = $data->[$i];
# for my $j (0..$#columns) {
# next unless defined $row->[$j];
# my $field_idx = $field_idxs[$j];
# next unless $field_idx >= 0;
# my $fmt_name = $fmt_names[$j];
# next unless $fmt_name;
# my $fmt_opts = $fmt_opts [$j];
# if ($fmt_name eq 'iso8601_datetime' || $fmt_name eq 'iso8601_date') {
# if ($row->[$j] =~ /\A[0-9]+\z/) {
# my @t = gmtime($row->[$j]);
# if ($fmt_name eq 'iso8601_datetime') {
# $row->[$j] = sprintf(
# "%04d-%02d-%02dT%02d:%02d:%02dZ",
# $t[5]+1900, $t[4]+1, $t[3], $t[2], $t[1], $t[0]);
# } else {
# $row->[$j] = sprintf(
# "%04d-%02d-%02d",
# $t[5]+1900, $t[4]+1, $t[3]);
# }
# }
# } elsif ($fmt_name eq 'boolstr') {
# $row->[$j] = $row->[$j] ? "yes" : "no";
# } elsif ($fmt_name eq 'sci2dec') {
# if ($row->[$j] =~ /\A(?:[+-]?)(?:\d+\.|\d*\.(\d+))[eE]([+-]?\d+)\z/) {
# my $n = length($1 || "") - $2; $n = 0 if $n < 0;
# $row->[$j] = sprintf("%.${n}f", $row->[$j]);
# }
# } elsif ($fmt_name eq 'percent') {
# my $fmt = $fmt_opts->{sprintf} // '%.2f%%';
# $row->[$j] = sprintf($fmt, $row->[$j] * 100);
# } elsif ($fmt_name eq 'number') {
# $nf //= do {
# require Number::Format;
# Number::Format->new(
# THOUSANDS_SEP => $fmt_opts->{thousands_sep} // ',',
# DECIMAL_POINT => $fmt_opts->{decimal_point} // '.',
# DECIMAL_FILL => $fmt_opts->{decimal_fill} // 1,
# );
# };
# $row->[$j] = $nf->format_number(
# $row->[$j], $fmt_opts->{precision} // 0);
# }
# }
# }
# }
#
# if ($format eq 'text-pretty') {
# {
# no warnings;
#
# my $tfa = $resmeta->{'table.field_aligns'} or last;
# last unless @$data;
#
# for my $colidx (0..$#columns) {
# my $field_idx = $field_idxs[$colidx];
# next unless $field_idx >= 0;
# my $align = $tfa->[$field_idx];
# next unless $align;
#
# my $maxw;
# my ($maxw_bd, $maxw_d, $maxw_ad);
# if ($align eq 'number') {
# my (@w_bd, @w_d, @w_ad);
# for my $i (0..$#{$data}) {
# my $row = $data->[$i];
# if (@$row > $colidx) {
# my $cell = $row->[$colidx];
# if ($header_row && $i == 0) {
# my $w = length($cell);
# push @w_bd, 0;
# push @w_bd, 0;
# push @w_ad, 0;
# } elsif ($cell =~ /\A([+-]?\d+)(\.?)(\d*)\z/) {
# push @w_bd, length($1);
# push @w_d , length($2);
# push @w_ad, length($3);
# } elsif ($cell =~ /\A([+-]?\d+\.?\d*)([eE])([+-]?\d+)\z/) {
# push @w_bd, length($1);
# push @w_d , length($2);
# push @w_ad, length($3);
# } else {
# push @w_bd, length($cell);
# push @w_bd, 0;
# push @w_ad, 0;
# }
# } else {
# push @w_bd, 0;
# push @w_d , 0;
( run in 3.796 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )