Data conversion example in Perl

May 4, 2008 at 12:15 am | Posted in perl | 1 Comment

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"; } } close(INPUT) [/sourcecode]


1 Comment »

RSS feed for comments on this post. TrackBack URI

  1. Vue comme u00e7a, c’est une expu00e9rience tru00e8s tentante.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at
Entries and comments feeds.

%d bloggers like this: