#! /bin/sh
#!perl -w # --*- Perl -*--
eval 'exec perl -x $0 ${1+"$@"}'
    if 0;
#------------------------------------------------------------------------------
#$Author: antanas $
#$Date: 2019-12-05 21:08:48 +0200 (Thu, 05 Dec 2019) $ 
#$Revision: 7546 $
#$URL: svn+ssh://www.crystallography.net/home/coder/svn-repositories/cod-tools/tags/v3.0.1/scripts/formula_sum $
#------------------------------------------------------------------------------
#*
#* Parse and print the chemical formula sum as described in the CIF
#* _chemical_formula_sum data item.
#*
#* USAGE:
#*   $0 sum.lst
#*   $0 sum1.lst sum*.lst
#**

use strict;
use warnings;
use COD::SOptions qw( getOptions );
use COD::SUsage qw( usage );
use COD::ToolsVersion;

#* OPTIONS:
#*   --help, --usage
#*                     Output a short usage message (this message) and exit.
#*   --version
#*                     Output version information and exit.
#**
@ARGV = getOptions(
    "--help,--usage"    => sub { usage; exit },
    '--version'         => sub { print 'cod-tools version ',
                                 $COD::ToolsVersion::Version, "\n";
                                 exit }
);

@ARGV = ("-") unless @ARGV;

use COD::Formulae::Parser::IUCr;

foreach my $filename ( @ARGV ) {
    my $p = COD::Formulae::Parser::IUCr->new;
    $p->Run($filename);
    $p->PrintFormula;
}
