Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.