Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env perl6
- # notes:
- # a run on juvat2 (2016-01-31) with 10 Gb input file was 22m25s
- # a run on bigtom (2016-01-31) with 10 Gb input file was 23m11s
- # the time for 'wc' on juvat2 was 1m57s
- # the time for 'wc' on bigtom was 1m30s
- my $prog = $*PROGRAM.basename;
- if !@*ARGS.elems {
- say "Usage: $prog <input file>" ~ "\n";
- exit;
- }
- my $ifil = shift @*ARGS;
- die "FATAL: file '$ifil' not found.\n"
- if !$ifil.IO.f;
- my $fsiz = $ifil.IO.s;
- say " File '$ifil' size: $fsiz bytes";
- my $nlines = 0;
- my $nchars = 0;
- for $ifil.IO.lines -> $line {
- ++$nlines;
- $nchars += $line.chars;
- }
- # adjust for newlines being removed
- $nchars += $nlines;
- say " Normal end.";
- say " For input file '$ifil':";
- say " Number lines: $nlines";
- say " Number chars: $nchars";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement