#!/usr/bin/perl
#
# Written by Dave Yearke, dave@yearke.net
#

use Gedcom;

die "Usage: $0 <GEDCOM file>\n" if ($#ARGV < 0);

$gedcom_file = @ARGV[0];
die "Can't find GEDCOM file \"$gedcom_file\"" if (! -f $gedcom_file);
print "Using GEDCOM file: $gedcom_file\n\n";

$gedcom = Gedcom->new(gedcom_file => $gedcom_file);

foreach my $person ($gedcom->individuals) {
    if (length($person->religion) > 0) {
        ++$religions{$person->religion};
    } else {
        ++$unspecified;
    }
}
foreach my $religion (sort keys %religions) {
    if ($religions{$religion} == 1) {
        print "There is " . $religions{$religion} . " person ";
    } else {
        print "There are " . $religions{$religion} . " people ";
    }
    print "of the " .  $religion . " faith.\n";
}
print "There are $unspecified people with no specified religion.\n";
