[geeks] perlish disgruntlement, java considered, sun hardware sought
David Cantrell
david at cantrell.org.uk
Mon Apr 8 05:33:08 CDT 2002
On Sun, Apr 07, 2002 at 08:53:46PM -0400, alex j avriette wrote:
> We're not talking about short cuts here. We're talking about clear and
> concise code. If you cant understand map and would prefer foreach, well,
> thats fine. But my code is going to gain that 10% efficiency for its
> 5,000,000 iterations.
Did you bother benchmarking your nested maps against my solution using a
single foreach?
> Reducing code is fine with proper indentation. A professional perl
> programmer can easily understand concise code:
>
> my %hash = map { chomp; /^([^@]+)@([^\s]+)$/ ? ($1 => $2) : () }
> read_file("filename")
Errm, proper indentation? You should indent the second line there so that
it is obvious it is really part of the first and not to be read on its own :-)
And you mean \S, not the harder-to-read [^\s].
If you're going to pontificate on perl style, it's a good idea to learn the
language first.
> right now im migrating a > 20,000 line perl program from one e3000 to a
> cluster of two e3500's with a new nfs cluster (also two e3500's). the
> code is hideous. a bug we recently encountered:
>
> $output = `rsh username hostname command args`;
> ($onevar, $twovar) = split(' ',$output);
>
> i'm sure you find that very readable. i find it hideous and abhorrent.
It is indeed very readable. The only bug I can see is that there is no
error-checking (although that might be done later by looking at the contents
of the two variables, I can't tell from that snippet).
> your c professor would fail you for making system calls in code.
I don't give a rat's arse what your C professor would do. This isn't C,
and I'm not a student.
> if youre not writing code that is *fit* to be passed from person to
> person, you shouldnt be writing code.
so if the shell porogramwhich I use for publishing my website is a dog's
breakfast, I shouldn't have written it at all? How, pray, is one meant
to learn to program if one isn't allowed to write one's first non-
trivial program in $language? That particular shell program is ugly,
but I have learnt from it. My next shell program will be better. That
one though - I can't be bothered to fix it, cos it does the job *and* is
for my use only so no-one else needs to understand it. Hell, *I* don't
need to understand the code any more.
--
Grand Inquisitor Reverend David Cantrell | http://www.cantrell.org.uk/david
"There seems to be something wrong with our ships today"
-- Rear-admiral Sir David Beatty, on seeing the Queen Mary
and the Indefatigable destroyed at the Battle of Jutland
More information about the geeks
mailing list