Yes, that works just fine. Thanks!
Phil
On Mar 25, 2009, at 11:09 PM, Stephen Woodbridge wrote:
This should work for the formats you show.
if ($date =~ m/^\s*(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)
\s+(\d+)\s*$/i) {
print "ERROR: date has month($1) and year($2) but no day: $date\n";
}
-Steve
Philip Durbin wrote:
I'd like to detect when a date in my GEDCOM file contains a year
and a month but no day, such as "FEB 1978".
I've written a small test (below) that you can run with "prove
datebug.t". The answer I'm looking for is the proper $condition
for the if statement in datebug.pl (also below).
Gedcom::Date says "the Gedcom standard for genealogical data files
defines a number of date formats" so it would be nice if the
solution would work not just for the format my dates happen to use
(i.e. 24 MAR 1964, which is what GRAMPS exported), but for any
GEDCOM dates. That said, I would (selfishly) be content with a
solution that only works for dates like mine. :)
Thank you very much for your help!
Phil
[pdur...@macbook tmp]$ cat datebug.pl
#!/usr/bin/perl
use strict;
use warnings;
while (my $line = <DATA>) {
chomp $line;
my ($name, $date ) = split(/:/, $line);
# what should the condition be?
my $condition;
if ($condition) {
print "ERROR: date has month and year but no day: $date\n";
}
}
__DATA__
Person1:FEB 1978
Person2:1 APR 1917
Person3:JUL 1973
Person4:24 MAR 1964
[pdur...@macbook tmp]$
[pdur...@macbook tmp]$ cat datebug.t
use strict;
use warnings;
use Test::More tests => 1;
is(
`./datebug.pl`,
"ERROR: date has month and year but no day: FEB 1978
ERROR: date has month and year but no day: JUL 1973\n",
'datebug.pl is ok'
);
[pdur...@macbook tmp]$