#!/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 ; }