Mercurial > hg > Members > anatofuz > anatofuz-tools
diff perl-wc @ 0:78df974566a7
initial commit
author | Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 12 Nov 2018 19:56:42 +0900 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/perl-wc Mon Nov 12 19:56:42 2018 +0900 @@ -0,0 +1,16 @@ +#!/usr/bin/perl +use strict; +use warnings; +use Encode; + +my $buffer = do { local $/; <>; }; + +my $strings = decode_utf8($buffer); + +my $lines = $strings =~ s/\n/\n/g || 1; +my $chars = length($strings); +my $bytes = length($buffer); + +print "lines: $lines\n"; +print "chars: $chars\n"; +print "bytes: $bytes\n";