|
Henry Troup wrote: Reading Perl is hard; writing it is easy
It's a "write once, read never" language.
Kevin
|
|
|
|
|
Program, Execute, Relax and Let it go
|
|
|
|
|
Actually, well-written perl programs/libraries (not the one-liners I also use) tend to be at least
as readable as C or C++, often more so. When I write longer perl programs I tend to use the same
commenting and indenting rules for all 3 languages.
But because perl is also a good tool for one-off quick-and-dirty stuff and one-liners embedded in batch files/shell scripts/makefiles etc., some perl programmers fail to write readable code even when not doing such tasks.
Of cause like for any other language, understanding the breadth and depth of the language is needed to read other peoples code fluently. If you don't understand the notation and common idioms, even beautiful code like this can be hard to read:
#!/usr/bin/perl
# Accumulate and format the foobar table data
use warnings;
use strict;
use 5.6;
my $tot = 0;
while (<> ) {
s/^\s+
next if /^#/;
s/\s+\z
while (/\s\\\z/ and defined(my $cont = <> )) {
$cont =~ s/^\s+
next if $cont =~ /^#/;
$cont =~ s/\s+\z
s/\s*\\\z/\n $cont/s;
}
s/\s*\\?\z
next if /^\s*\z/s;
if (/^(\S+)\s+([-+]?\d+)\s+(.*)\z/s) {
$tot += $2;
printf "\%-10s \%10d \%s\n", $1, $tot, $3;
} else {
print STDERR "Unknown line ",$ARGV,"(",$.,"): '",$_,"'\n";
}
}
(Explanation: Parse all input lines, skip #-style comment lines, join \-style continuation lines but keep the line feeds and indent the continuations 22 columns, skip blank resulting lines, accumulate signed integers in the second column and output with total as second column, left align columns 1 and 3, right align the numeric column. Column 3 is optional and will be indented 22 columns. Warn about any input not matching the expected format).
P.S.
I am sure this could be written shorter with some additional libraries or idioms, this was written to illustrate readability, not a shortest-obfuscated-perl contest.
This message is hasty and is not to be taken as serious, professional or legally binding.
I work with low level C/C++ in user and kernel mode, but also dabble in other areas.
|
|
|
|
|
The worst is mod_Perl
Cheers
Marcello Turnbull
|
|
|
|
|
mike.strobel wrote: I avoid [...] Java like the plague
moron
|
|
|
|
|
that have a CListCtrl class.
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein
"How do you find out if you're unwanted if everyone you try to ask tells you to stop bothering them and just go away?" - Balboos HaGadol
"It's a sad state of affairs, indeed, when you start reading my tag lines for some sort of enlightenment. Sadder still, if that's where you need to find it." - Balboos HaGadol
|
|
|
|
|
Get with it. That thing's better off in a museum....
Regards,
Rob Philpott.
|
|
|
|
|
Blasphemy !
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein
"How do you find out if you're unwanted if everyone you try to ask tells you to stop bothering them and just go away?" - Balboos HaGadol
"It's a sad state of affairs, indeed, when you start reading my tag lines for some sort of enlightenment. Sadder still, if that's where you need to find it." - Balboos HaGadol
|
|
|
|
|
Isn't that part of a library? Not part of a language?
|
|
|
|
|
Precisely.
If the language has it in its library, all is well, or, at least may be well.
If it doesn't, it isn't, shouldn't, and won't.
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein
"How do you find out if you're unwanted if everyone you try to ask tells you to stop bothering them and just go away?" - Balboos HaGadol
"It's a sad state of affairs, indeed, when you start reading my tag lines for some sort of enlightenment. Sadder still, if that's where you need to find it." - Balboos HaGadol
|
|
|
|
|
So... if the library is accessable from COBOL...
|
|
|
|
|
From My Post:
". . . at least may be well."
i.e., necessary, but not necessarily sufficient;
Please refer to CListCtrl postings from prior Lounge-wear/ware/where for a suitable explanation that may well assuage your confused state.
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein
"How do you find out if you're unwanted if everyone you try to ask tells you to stop bothering them and just go away?" - Balboos HaGadol
"It's a sad state of affairs, indeed, when you start reading my tag lines for some sort of enlightenment. Sadder still, if that's where you need to find it." - Balboos HaGadol
|
|
|
|
|
I'd be right in there with the crowd who prefers their favorite language but will work in others if only I had a favoriate language. I've yet to find one that isn't obstructively klunky in some way or another, but they are all balanced by being sublimely elegant in some other way.
patbob
|
|
|
|
|
patbob wrote: balanced by being sublimely elegant in some other way.
... except COBOL.
|
|
|
|
|
You know about the OO dialect of COBOL, right?
ADD_ONE_TO_COBOL_GIVING_COBOL
Henry in Ottawa
|
|
|
|
|
I suppose.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
If you don't ask questions the answers won't stand in your way.
Most of this sig is for Google, not ego.
|
|
|
|
|
Admittedly I never worked with Ada, but it looks like a very well designed language to me, and has a nice syntax as well. Why don't you like it?
|
|
|
|
|
Had to use it in comparative languages in college. Absolute nightmare to do complicated stuff that should have been easy.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
If you don't ask questions the answers won't stand in your way.
Most of this sig is for Google, not ego.
|
|
|
|
|
VB.Net is my favorite. Can't stand ADA. Or Pascal for that matter. COBOL is the WORST. Rots your brain right away.... ;~)
|
|
|
|
|
Owen37 wrote: Rots your brain right away
And VB does so more slowly?
|
|
|
|
|
It's not VB.Net that rots your brain, It's Intellisense. VB.Net is an excellent language with a bad stigma. C# is a C++/Java wanna-be language. Admittedly, C# is a decent language, but it's not all it's hyped to be. Anyone who wants to code the machine can attest to that.
|
|
|
|
|
Ha! Didn't think it would take long for the anti-VB zealots to crawl out of the woodwork.
Kevin
|
|
|
|
|
Not wanting to do it does not make me an anti-vb zealot.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
If you don't ask questions the answers won't stand in your way.
Most of this sig is for Google, not ego.
|
|
|
|
|
No, I suppose not. But there are quite a few zealots here nonetheless.
Kevin
|
|
|
|
|
Ha! Didn't think it would take long for the anti-COBOL zealots to ooze out of the slime...
|
|
|
|