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]

Advertisements

1 Comment »

RSS feed for comments on this post. TrackBack URI

  1. Vue comme u00e7a, c’est une expu00e9rience tru00e8s tentante.https://ameo.link/lenafigueroa1879308180


Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 WordPress.com.
Entries and comments feeds.

%d bloggers like this: