aboutsummaryrefslogtreecommitdiff
path: root/challenge-028/arne-sommer/perl6/bytecount
blob: 723e9356af3b4b37da598a915c1f5fe5fcc5f6e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#! /usr/bin/env perl6

multi sub MAIN ($file where $file.IO && $file.IO.r)
{
  my $fh = open $file, :bin;
  count-blob($fh.read);
  $fh.close;
}

sub count-blob ($blob)
{
  my @count;

  @count[$_]++ for @$blob;

  for ^@count -> $index
  {
    say "$index: { @count[$index] }" if @count[$index];
  }
}