_dodger opened this issue on Dec 19, 2002 ยท 18 posts
_dodger posted Sat, 21 December 2002 at 4:03 AM
Attached Link: More than you ever wanted to know about Perl, plus dodger's modules!
Note: it's perl, not pearl. A pearl is an encapsulated mullusc irritant. Perl is 'Practical Extraction and Report Language'. Or perhaps 'Pathologically Eclectic Rubbish Lister'. It's up for debate, but both are good things, especially when you have to list pathologically eclectic rubbish, like the contents of a PZ3 file. Or feed it into a relational database. In Oregon. Or spit it back out as something different. Perl's originally derived from a combined permutation/combination of sed, awk, csh, and c. It's evolved into an entirely different camel since then, though B^) Honestly, I couldn't tell you, because I don't know Python much at all. As far as specifically for Poser goes, well, I'm planning on writing a module called Object::Poser one of these days and if it works well, putting it up for free on CPAN. This, in python: while 1:
buf =index.html fp.read(blocksize)
if not buf: break
conn.send(buf)
would be this, in perl: while (1) { $buf = $fp->read($blocksize); last if not $buf; $conn->send($buf); }
But Perl lets you have more leeway in how you say things. For instance, you can also say: while (1) { $buf = $fp->read($blocksize) or last; $conn->send($buf); }
Which I find a lot more readable, and it does exactly the same thing. So at least in this example I found, you can go one line less, or 25% down. And it looks a lot more like natiral language to me. Oh, yeah, and in Perl curly braces are an absolute necessity, but indentation is merly highly recommended. I've seen entire programs written on one line, though, and they worked. Well, mostly. The reason I saw them is because it was my job to debug them. Which is why I highly recommend proper indentation in Perl anyway.