Skip to content

Instantly share code, notes, and snippets.

@amatubu
Created March 15, 2013 11:42
Show Gist options
  • Save amatubu/5169308 to your computer and use it in GitHub Desktop.
Save amatubu/5169308 to your computer and use it in GitHub Desktop.
Count spices
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
my %spices;
open my $blend_file, "blendlist.txt";
die "ブレンドリストが開けません。" if !$blend_file;
while ( my $blend = <$blend_file> ) {
if ( $blend =~ m/(\w+)\s(\w+)/ ) {
my ( $spice1, $spice2 ) = ( $1, $2 );
$spices{$spice1}++;
$spices{$spice2}++;
}
}
for my $spice ( sort keys %spices ) {
printf "%12s %2d\n", $spice, $spices{$spice};
}
exit 0;
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment