Mailinglist Archive: opensuse-factory (757 mails)

< Previous Next >
Re: [opensuse-factory] Learning Perl (Was: Re: [opensuse-factory] tagmedia question)
  • From: PJakobi@xxxxxxxxxxx (Peter Jakobi)
  • Date: Fri, 5 May 2006 16:12:10 +0200
  • Message-id: <200605051412.k45ECAtP032098@xxxxxxxxxxxxxxxxxx>
You write:

Houghi,

>I tried it and I just can't get the hang of it. 'man perl' confuses me
>more then that it helps me.

'man perl', or things like 'perldoc -f sort' are things to
jog your memory, not things to learn perl with...


Larry and co somewhere have some sayings about perl:

1. there's many ways to do things
2. make easy things easy (even to guess what the user really wanted), but
make hard things possible.

So:

The Good:

- saying 1 means there are many idiomatic conventions to use
Perl. Say just rewrite a C program 1:1 in perl, upto C's
for and while statements, and your convention for translation
a case cascade.

Say just rewrite a shell script using awk.

In both cases, perl's syntax allows you to retain most
of the syntactic and semantic structure of say C or AWK.
Perl even supports awk's BEGIN blocks, so you've to peek
that the #! line on top to be sure you're reading perl...

Or lisp. Perl has lists, and map (plus shortcuts like
pop,unshift, grep, ...). cdr is missing, but you just use
shift. Lambda objects are function refs, etc. Everything's
there, except the visual appeal of being able to have a
syntactically necessary lines finishing with a block of
20+ closing parantheses. Saner persons than RMS however
cite this as the sole reason to avoid lisp :).

perl baby talk's fine.

Or a decide later an idiomatic open or die stanza followed
by a schwartzian transform-resort of file data. What on
the commandline would be something like map|sort|map.
Functional programming and lisp also comes to mind.


The Ugly:

- obfuscation is easy. also unintentional obfuscation.
So self-discipline is a bit more important than in more
restrictive - or crippled - environments elsewhere.

- perl5 has support to create your own OO-"Language" on top of it.
However it is decidedly no object-oriented language.
[ok, this is opionated, but unless one has a SINGLE RIGHT one way
to use e.g. inheritance and overload my parent's functions
within a well-defined oo interface, the language just isn't
oo. Just like C. Not if every one develops his/her own OO inheritance
conventions. Heck, you can never be sure of object itself: does the modul
I'd like to reuse use a scalar or a blessed hash as base for his objects??

Saying1 vs. Perl5 = 1 : 0, Perl5 standing, but with hole shot in foot.]

Python wins here, as well as that rumoured new language to be
called perl 6. being able to _BREAK_ any perl5 syntactic rules.


>Then I started to put in a "for" for the booting and copying and started to
>make it more generic. A bit later added some features.

Which is just fine when using perl for small, single-authored scripts...

:)
Peter

--
cu
Peter
jakobi@xxxxxxx

< Previous Next >
Follow Ups