Bin-Data-1D
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
scripts/wc-l view on Meta::CPAN
#!/usr/bin/perl
use 5.001 ; use strict ; use warnings ; # 5.014 ã§åä½ç¢ºèªæ¸ã¿
use autodie qw[ open ] ;
use Getopt::Std ; getopts 'bd:gsnrz=~!3":' , \my%o ;
use Term::ANSIColor qw/:constants color / ; $Term::ANSIColor::AUTORESET = 1 ;
use Scalar::Util qw[ dualvar ] ; # <-- dualvar ã®å©ç¨ã¯ããã¾ã好ã¾ãããªãå¯è½æ§ã¯ããã試ãã«ä½¿ã£ã¦ã¿ãã
use FindBin qw [ $Script ] ;
use Encode qw[ decode ] ;
use Encode::JP ;
eval "use PerlIO::gzip;1" or die "Can't import PerlIO::gzip despite -z instruction. ($Script)\n" if $o{z} ;
sub main ( ) ; # å
¥åãé 次å¦çãã
sub eachFile ( $ ) ; # å¼æ°ã§æå®ãããåãã¡ã¤ã«ãå¦çãã¦ãè¡æ°ãè¿ãã
sub lineNum ( $ ) ; # (åãã¡ã¤ã«ããä¸ãããã) ãã¡ã¤ã«ãã³ãã«ãããè¡æ°ãè¿ãã
sub sigint ( ) ; # Ctrl-C ãæ¼ä¸ãããæã®å¦ç
sub hhmmss ( ) ; # ç¾å¨æå»ã yyyy-mm-dd HH:MM:SS ã®å½¢ã§è¿ãã
sub cyc_rep ( ) ;
$/ = "\r\n" if $o{r} ;
#$/ = "" ;
$| = 1 if $o{'!'} ;
* CYAN = * BRIGHT_CYAN = * BLUE = * BRIGHT_BLUE = sub { @_ } if $o{b} ; # <-- TRICKY A LITTLE.
my ($time0, $time00) = (time) x 2 ;
my $cyc_sec = $o{'"'} // 10 ; # ä½è¡æ¯ã«ã¬ãã¼ããçºçããããã
my $cyc_last_line ; #
my $noLineEnd = 0 ; # è¡æ«ã®æåãæ¹è¡(æ£ç¢ºã«ã¯ $/ ) ã«ä¸è´ããªãã£ããã¡ã¤ã«ã®åæ°
my $dirnum = 0 ; # ãã£ã¬ã¯ããªã®åæ°
my $fn ; # èªãã§ãããã¡ã¤ã«ã®åå
my $FH ; # ãã¡ã¤ã«ãã³ãã«
main ;
exit 0 ;
sub main ( ) {
my $time00 = time ;
my $total_lines = 0 ; # å
¨ãã¡ã¤ã«ã®è¡æ°ã®åè¨
@ARGV = ( '-' ) unless @ARGV ;
$SIG{INT} = \& sigint ; ## \sigint
$total_lines += eachFile $_ for @ARGV ;
* BLUE = * BRIGHT_BLUE ; # <-- - TRICKY !
#my $fn ; # åè¨ã®é
ç®ã§ãããã¨ã表ãæåå
$fn = (scalar @ARGV - $dirnum). " files" ;
$fn .= " plus $dirnum directories" if $dirnum > 0 ;
$fn = "[- $fn -]" ;
out1line ( dualvar ($total_lines , -"$noLineEnd" ) , $fn , $time00 ) if @ARGV >= 2 ; # 1åããå
¥åãç¡ãå ´åã¯åºããªãã
}
# åãã¡ã¤ã«ã«å¯¾ããdualvarã§è¡æ°ã¨EOFç¶æ
ãè¿ãããã¡ã¤ã«åããè¡æ°ãè¿ãé¢æ°ãèµ·åãããããåºåããé¢æ°ãèµ·åããã
sub eachFile ( $ ) {
my $time0 = time ;
$fn = $_[0] ;
# ãã¡ã¤ã«ãã³ãã©ãè¨å®ã"-" ãªãæ¨æºå
¥åã
if ( $_[0] ne "-" ) {
if ( ! $o{g} ) {
open $FH , '<' , $_[0]
} else {
open $FH , '-|' , 'gzcat' , $_[0] ;
#open $FH [ $_ ] , '-|' , 'gzcat' , $ARGV[$_] ; # open $FH, "gzcat '$ARGV[$_]' |" ããè¯ãã¨æã£ã
}
} else {
$FH = * STDIN
} ;
binmode $FH , ":gzip(gzip)" if $o{z} ;
my $header = <$FH> if $o{'='} ; # <-- ä¸å¿æå³ã¯ããã-+ ã¹ã¤ãããªãã·ã§ã³ã§å¯¾å¿ã§ããªãã?
my $ret = lineNum $FH ;
out1line ( $ret , $fn , $time0 ) ;
return $ret ;
}
# ãã¡ã¤ã«ãã³ãã©ããè¡æ°ãè¿ãã
sub lineNum ( $ ) {
my $last_count = $. ;
my $FH = $_[0] ;
my $count = 0 ;
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.386 second using v1.00-cache-2.02-grep-82fe00e-cpan-d29e8ade9f55 )