Re: [Nolug] Evo and Outlook

From: Mark A. Hershberger <mah_at_everybody.org>
Date: Sat, 12 Jul 2003 03:57:00 -0500
Message-ID: <873chcazs3.fsf@everybody.org>

Ron Johnson <ron.l.johnson@cox.net> writes:

> I'm slightly above newbie regarding REs, and, IMHO, they *are*
> line noise. Powerful line noise.

Some things are virtually impossible w/o regular expressions.
Perl-style REs have been incorporated into many languages and tools
(by virtue of the pcre library). PHP, Python, Exim and others are
all beneficiaries.

Consider Regular Expressions a mini-language that you can learn once
and use in lots of different places. There's the idiosyncrasies that
come with different dialects (sed's REs are different in annoying
ways), but if you've got the language the dialects aren't that
difficult.

> I've tried learning Perl, but the pain threshold is so much lower
> for Python. Writing something to, for example, go thru a directory
> converting all spaces in filenames is much shorter in Perl than
> in Python, but a Python newbie who knows how to program (but has
> not joined The Unix Cult) would understand the code, whereas s/he
> would be baffled by the Perl code.

Perl:

for(<*>) {if(/ +/) {$o=$_;s/ +/_/g;rename $o,$_}}

Python:

for file in os.listdir("."):

  if file.find(" ") != -1:

    rename file, re.sub(" ", ".", file)

By the way, I don't know Python, I just pick up new languages. Lisp
is the hardest one I've had to pick up, but also, in some ways, the
most powerful.

In other ways, Perl is the most powerful. CPAN is an amazing resource
an no other language comes close to that kind of utility.

Mark.
___________________
Nolug mailing list
nolug@nolug.org
Received on 07/12/03

This archive was generated by hypermail 2.2.0 : 12/19/08 EST