App-Bin4TSV
view release on metacpan or search on metacpan
scripts/colchop view on Meta::CPAN
# åºåããæååã®é·ãã®æå¤§å¤ã¨æãè¿ãæ°ã®æå¤§å¤
my ($tlen, $tmax) = do { ($o{g}//='') =~ m/(\d*)\D?(\d*)/ ; ( $1 || 6 , $2 // 2 || "Inf") } ;
#say STDERR $tlen,' ', $tmax;
my $existNext = $o{'.'} // '.' ; # ã¾ã表示ãè¶³ããªãæã«ãã»ã«æ«ã«æ¿å
¥ããæåå
my $iosep = $o{'/'} // "\t" ; # å
¥åºåã®åºåãæå
binmode STDIN, ":encoding(utf8)" if ! $o{w} && $o{u} ; # binmode ã®æå®ã¯ã substr颿°ã«å½±é¿ããã
binmode STDIN, ":encoding(cp932)" if $o{w} ; # <-- - SJIS <<? "cp932" çµµæåãèããã
binmode STDOUT,":encoding(utf8)" if $o{u} || $o{w} ; #$/ = "\r\n" if $o{W} ;
& main ;
exit ;
sub aLinOut ( @ ) {
my @cells ;
for ( 1 .. $#_ ) { # åãã¹ã®æååã«ã¤ãã¦.. ( $_ ã¯1å§ã¾ãã§å·¦ããä½çªç®ãã表ã )
push @cells , undef and next if ! defined $_[$_] ; # æªå®ç¾©ãªãæªå®ç¾©ã¨ãã¦
my $str = $_ <= $o{h} ? $_[$_] : trim ( $_[$_] , $tlen ) ; # -h ã§å·¦ããããã¤ãã®åã¯ä¿è·ããæå®ãããã°ããã®ããã«ã㦠..
$_[$_] =~ s/^\Q$str\E// ;
$_[$_] = undef if $_[$_] =~ m/^$/ ;
push @cells , $str . ( defined $_[$_] ? $existNext : '' ) ;
}
unshift @cells , "$_[0]" if defined $_[0] ;
say join $iosep , map { $_ // '' } @cells ;
}
sub main ( ) {
while ( <> ) {
chomp ;
my $lc = "$.:" if $o{':'} ; # -: æå®ã§ãè¡çªå·ã1åã ã表示 LineCount
my @F = split /$iosep/o , $_ , -1 ;
#for ( my $t=0 ; ++$t <= $tmax ; ) { aLinOut ($lc, @F) ; $lc = '' ; last if ! any { defined $_ } @F }
for ( my $t=0 ; ++$t <= $tmax ; ) { aLinOut $lc, @F ; last if ! any { defined $_ } @F }
}
}
## ãã«ãã®æ±ã
sub VERSION_MESSAGE {}
sub HELP_MESSAGE {
use FindBin qw[ $Script ] ;
$ARGV[1] //= '' ;
open my $FH , '<' , $0 ;
while(<$FH>){
s/\$0/$Script/g ;
print $_ if s/^=head1// .. s/^=cut// and $ARGV[1] =~ /^o(p(t(i(o(ns?)?)?)?)?)?$/i ? m/^\s+\-/ : 1;
}
close $FH ;
exit 0 ;
}
=encoding utf8
=head1
$0 -bg (ãã¤ãæ°)(,æãè¿ãã®æå¤§å¤)
$0 -ug (UTF-8ã®æåæ°)(,æãè¿ãã®æå¤§å¤)
$0 -vg (åè§æåå¹
)(,æãè¿ãã®æå¤§å¤)
ã¿ãæåãªã©ã§åºåãããåãã£ã¼ã«ãããæå®ãããå¹
ã®ã¿è¡¨ç¤ºããã
Unix/Linux ã®ãtabs ã³ãã³ãã§è¡¨ç¤ºè¨å®ãå¤ããªããè¦ãã®ãè¯ãã
ãã¥ã¼ã¢less ãèµ·åä¸ã« -x N(æ°) ã¨å
¥åãã¦Enter ãããã®è¯ãã
ãªãã·ã§ã³ :
-b : ãã¤ãæ°ã§è¨ç®ããã
-u : utf-8 ã¨ã¿ãªãã¦ãé·ããè¨ç®ãããããã§ãªããã°ãåç´ãªãã¤ãé·ã«ãªãã
-v : utf-8 ã®æåå¹
ã§é·ããè¨ç®ãã(åè§ã¯1ãå
¨è§ã¯2)ã(visual-width)
-g N1,N2 : N1ã¯ä½æåãã¤åãåºãããæªæå®ãªã 6ãN2ã¯æå¤§ä½ååãåºããã0ãªãç¡å¶éãæªæå®ãªã2ã
-h N ; å·¦ããNåã®ã»ã«ã¯ãæãè¿ãå¦çãããªãã<--
-w ; CP932 (SJIS)ã¨ãã¦å¦çãããã
-. STRING ; ã»ã«å
æ¹è¡ã®æ«å°¾ã«ä»ããæååã | ãã夿´ããã
-/ REGEX : å
¥åºåã®åºåãæåã®ã¿ãæåããã®å¤æ´ã
-: ; è¡çªå·ãåºåã
-! : ãã©ãã·ã¥ããããããã¡ã«è²¯ããªãã
--help : ãã® $0 ã®ãã«ãã¡ãã»ã¼ã¸ãåºãã perldoc -t $0 | cat ã§ãã»ã¼åãã
--help opt : ãªãã·ã§ã³ã®ã¿ã®ãã«ããåºããopt以å¤ã§ã options ã¨å
é ã1æå以ä¸ä¸è´ããã°è¯ãã
éçºã¡ã¢ :
* åè§ç©ºç½ã§ãæå¤§è¨±å®¹å¹
ã«è¶³ããªãåãåãããªãã·ã§ã³ãå®è£
ãããã
* -wã®ãã¹ããã§ãã¦ãªãã¯ãã
=cut
( run in 0.640 second using v1.01-cache-2.11-cpan-39bf76dae61 )