Data conversion example in Perl

This is a one-off to convert Dinesh Prabhu’s Romanized Urdu-English dictionary into comma separated value format (.CSV) to be opened in Microsoft Excel and then pasted into the Microsoft Excel workbook included with G√ľnther’s Vocabulary Cards for Palm.

open (INPUT, "< $ARGV[0]") || die "Can't open file $ARGV[0].\n";

while () {

	if ($_ =~ /([^\:]+)\:\s*([PATHSG])\s+(n.f.|n.m.|pron.|adj.|v.|adv.|intj.|prep.|suff.|pref.)\s+(.*)/)
		($urdu, $origin, $part, $english) = ($1, $2, $3, $4);
		print "\"$urdu \[$part\] \[$origin\]\",\"\",\"\",\"\",\"$english\"\n";