Guess I have to understand that script to rewrite it in Python. :->
First, gethead.pl reads through the file until it finds a line which starts with a '!'. In which case it creates a list of names of the form '$'column name:
$format = '$' . join(', $', split(/,/, $first_line));
print $format . "\n";
Yields:
> ./r.pl r.txt $started, $ended, $title, $company, $description
The magic really occurs in the main processing loop:
do main'read_txtfile_format(*LNG_FILE, *languages);
lang: while (<LNG_FILE>) {
next lang if (/^#/ || /^!/);
eval "($languages) = split(/[,\n]/)";
print "$started - $ended: $title for $company\n\t$description\n\n";
}
The first line gets '$languages' setup to the 'variable' names. Each time through the while loop, we call the eval to translate/associate the columns to variable names.