while (<>) {
chomp;
my ($name, $birth, $death) = m{
(.*?) # name of the composer ---> $name
\s+
(?:
(?:\d+\.){2} # day and month of birth (ignored)
)?
(\d{4}|\?) # year of birth ---> $birth
- # delimiter between birth and dth
(?:
(?:\d+\.){2} # day and month of death (ignored)
)?
(\d{4}|\?)? # year of death ---> $death
$
}x;
# complain if it didn't match
unless (defined $birth) {
print STDERR "$cmdname: invalid entry: $_\n";
next;
}
$db->db_put($birth, "Born: $name")
if defined $birth && $birth ne "?";
$db->db_put($death, "Died: $name")
if defined $death && $death ne "?";
}
|