Last active
August 29, 2015 13:56
-
-
Save glennklockwood/8792456 to your computer and use it in GitHub Desktop.
analyzecoord, Original Perl Implementation
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/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