[H-GEN] Perl as a text parser (was: Vi...)
Jason Henry Parker
jasonp at uq.net.au
Wed Aug 22 20:04:36 EDT 2001
[ Humbug *General* list - semi-serious discussions about Humbug and ]
[ Unix-related topics. Please observe the list's charter. ]
[ Worthwhile understanding: http://www.humbug.org.au/netiquette.html ]
Sarah Bernadette Kelly <sbk98 at uow.edu.au> writes:
> I totally agree though. I learnt python before perl, they each have
> their pros and cons, but I would use perl for anything that was
> primarily text processing,
Okay. One Jason Perl Rant (tm) coming up. Block your ears if you
don't want to hear it.
I really don't know where Perl's reputation for being good at text
processing and only text processing comes from. My gut tells me
it has something to do with Perl regular expressions, but really, if
that's all one wants, it's possible to simply use (GNU) sed unless
you're chasing stuff like s///e or cleaner syntax.
Perl is a good language for OO programming, quick prototyping, GUI
programming, filesystem hacks, system administration, database
queries, CGI scripts, JAPHs, and many, *many* things besides the old
mantra of `text processing'.
It's a very flexible language: want to write a subroutine that feels
just like a new builtin? No problem. Want to mess with the symbol
table, at run-time? Easy. Want to eval arbitrary code and stay safe?
Sure. Want to interface your script to C for speed, or Java for solid
coding? Yep. Want to play loose and fast with the rules? Want to be
tied up and spanked? Perl can do both.
I will now go out on a limb and assert it is at least as versatile as
Python, and almost as good as C for all but the most time-critical
stuff.
That said, my job this week is writing bunches of Perl to convert
about 5.5M records from flat text files into a normal form, and yes,
it most certainly does rawk.
Calling Perl a text-processing language is like calling Java a
language for writing applets.
> Before you start on a defense of
> perl,
I don't see myself as defending as much as, well, clarifying.
> I learnt python first. I'm used to python. I'm learning perl for an
> assignment, and it keeps breaking. I program faster in python at the
> moment. Hence it is a better tool at the moment.
Is your university teaching you Perl? In my experience, most of them
are not very good at it. If you have a question---and I'm not
offering to do anyone's homework---send it to me or the list and I'll
see what I can do for you.
(Oh, and yes, python is just fine. One day I may even learn it.)
jason
--
||----|---|------------|--|-------|------|-----------|-#---|-|--|------||
| There are no atheists when your jasonp at uq.net.au |
| boyfriend has lost his mind! -- AnnB #soc.bi on OPN |
||--|--------|--------------|----|-------------|------|---------|-----|-|
--
* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
* Postings to this list are only accepted from subscribed addresses of
* lists 'general' or 'general-post'.
More information about the General
mailing list