App-Bin4TSV
view release on metacpan or search on metacpan
scripts/backcolor view on Meta::CPAN
#!/usr/bin/perl
use 5.014 ; use strict ; use warnings ;
use Getopt::Std ; getopts 'd:s' ,\my%o ;
use FindBin qw [ $Script ] ;
use Term::ANSIColor qw[ :constants color ] ; $Term::ANSIColor::AUTORESET = 1 ;
use Scalar::Util qw[ looks_like_number ] ;
use List::Util qw[ min max ] ;
$o{d} //= 1 ; # è²ã1段éä¸ããã®ã«ãæ°å¤ãããã¤é«ãå¿
è¦ããããã
while ( <> ) {
my @F = do { chomp ; split /\t/o, $_ , -1 } ;
for ( @F ) {
if ( looks_like_number ( $_ ) ) {
my $n = $o{s} ? sqrt ( $_ ) : $_ ;
my $d = max 0, min 5, int $n / $o{d} ;
my $c = "on_rgb00$d" ;
$_ = color ($c) . $_ . color ('reset') ;
}
}
say join "\t", @F ;
}
=encoding utf8
=head1
$0
TSVãã¡ã¤ã«ã«ããã¦ãæ°å¤ã®ã»ã«ã«å¯¾ãã¦èæ¯ã«è²ãä»ããã
ãªãã·ã§ã³:
-d N ; æ°å¤/N ã«å¯¾å¿ãã¦6段éã®è²ãä»ããã
-s ; æ°å¤ã«å¯¾ãã¦å¹³æ¹æ ¹ãä½ç¨ãããã
=cut
## ãã«ãã¨ãã¼ã¸ã§ã³æ
å ±
BEGIN {
$Getopt::Std::STANDARD_HELP_VERSION = 1 ;
grep { m/--help/} @ARGV and *VERSION_MESSAGE = sub {} ;
our $VERSION = 0.11 ;
# æå㯠0.21 ãç®å®ã¨ããã
# 1.00 以ä¸ã¨ããå¿
è¦æ¡ä»¶ã¯è±èªçã®ãã«ãããã¡ãã¨åºããã¨ã
# 2.00 以ä¸ã¨ããå¿
è¦æ¡ä»¶ã¯ãã¹ãã³ã¼ããå«ããã¨ã
}
sub HELP_MESSAGE{
use FindBin qw[ $Script ] ;
$ARGV[1] //= '' ;
open my $FH , '<' , $0 ;
while(<$FH>){
s/\$0/$Script/g ;
print $_ if $ARGV[1] eq 'opt' ? m/^\ +\-/ : s/^=head1// .. s/^=cut// ;
}
close $FH ;
exit 0 ;
}
( run in 2.529 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )