Skip to content

Instantly share code, notes, and snippets.

@glennklockwood
Created February 3, 2014 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glennklockwood/8792652 to your computer and use it in GitHub Desktop.
Save glennklockwood/8792652 to your computer and use it in GitHub Desktop.
analyzecoord, New Version by gnustavo
#!/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