Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
analyzecoord, Original Perl Implementation
#!/usr/bin/perl
@show = qw/ Siloxane SiO4 Si3O SiO3 SiO2 SiO1 NBO FreeOH H2O H3O SiOH SiOH2 Si2OH/;
printf("\n%-8.8s ", "ird");
foreach $specie ( @show )
{
printf("%8.8s ", $specie);
}
print "\n";
$current = 0;
$isave = 0;
while ( $line = <> )
{
chomp($line);
$line =~ s/^\s+//g;
@arg = split(/\s+/, $line);
next unless $line =~ m/^\d+\s+[\d\w]+\s+\d+\s+[\w\.]+\s+[\w\.]+\s+[\w\.]+\s*$/o;
if ( $current == 0 )
{
$current = $arg[0];
$isave = $current;
}
if ( $arg[0] != $current )
{
&printargs();
$current = $arg[0];
$isave++;
}
$type{$arg[1]}++;
}
&printargs();
sub printargs( )
{
printf("%-8s ", $isave);
foreach $specie ( @show )
{
printf("%8d ", $type{$specie});
}
print "\n";
foreach $i ( keys(%type) )
{
$type{$i} = 0;
}
}
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.