It's a UNIX system, I know this...

Feb 04, 2009 01:52

wanteded to teik a brake from internets, but i addictd.

Kinda started playing around with Perl when I came home, and in the end rewrote my Bourne shell script for making tweets, adding interactive mode, which I so longed for, because I always would forget the names of userpics.

Here it is: http://www.s010.lv/files/addtweet.plx.

Perl is... NICE *_* It's a great pleasure to code in it. You may have heard that Perl's motto is There is more than one way to do it -- this matrializes in that you have almost no restrictions -- instead of thinking about the language's syntax, you can concentrate on solving the problem. You don't write Perl, Perl flows from your hands.

It has two advantages against Python: it is distributed in base install of almost all modern UNIXen; it's faster than Python.

And I dunno, I just seem to like Perl better.

Another great language from UNIX land is Awk -- it's a language that was specifically designed for text processing. I can't imagine my life without this great tool now. It's syntax is very similar to C, but much more human-friendly.

For example, I commented out the debug print statements in the above script with the following command:

awk '/^print[ ]".*/ { print "# " $0; next } { print $0 }' < addtweet.plx > newaddtweet.plx

Another example: I had to make a Python dictionary at work, it was too big to do manually (or maybe I was too lazy...), I had a file with the variable descriptions and names in the following form

Var1 long description blablabla = var1

So I easily transformed it to

"var1" : "", # Var1 long description blablabla

with an awk script like

BEGIN {
FS = " = "
}

/^$/
{
next
}

{
print "\"" $2 "\" : \"\", # " $1
}

An awesome tool I tell you. I read that Bourne shell and awk are the only two scripting languages that are always present on any UNIX system.

bragging, unix, awesome, happy, mad skillz, hobby/job, programming

Previous post Next post
Up