Created
February 3, 2014 21:20
-
-
Save glennklockwood/8792652 to your computer and use it in GitHub Desktop.
analyzecoord, New Version by gnustavo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use utf8; | |
use strict; | |
use warnings; | |
my @show = qw/Siloxane SiO4 Si3O SiO3 SiO2 SiO1 NBO FreeOH H2O H3O SiOH SiOH2 Si2OH/; | |
my %type; | |
@type{@show} = (0) x @show; | |
printf('ird ' . ' %8.8s' x @show . "\n", @show); | |
my $isave; | |
my $current; | |
my $linefmt = '%-8.8s' . ' %8d' x @show . "\n"; | |
while () { | |
if (my ($id, $specie) = (/^\s*(\d+)\s+([\d\w]+)\s+\d+(?:\s+[\w\.]+){3}\s*$/)) { | |
$current = $isave = $id unless defined $current; | |
if ($id ne $current) { | |
$current = $id; | |
printf($linefmt, $isave++, @type{@show}) ; | |
@type{@show} = (0) x @show; | |
} | |
++$type{$specie}; | |
} | |
} | |
printf($linefmt, $isave, @type{@show}) if defined $current; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment