#! perl while (<>) { if (/^=head2 (\S+) EVENTS/) { $klass = $1; } elsif (/=head3 (\S+)\s*(.*)/) { print "def ($klass, \U$1\E) // $2\n"; } }