I think some of the reason coders sometimes seek get things done in a single line is the resemblance of perl to natural language. Larry's roots as a linguist are reflected in the language he built.
Constructs like
open(F, ">foo.txt") or die "hey, couldn't open foo.txt";
resemble how we talk, rather than the more formal
if (!open(F, ">foo.txt")) {
die "hey, couldn't open foo.txt";
}
Somehow, opening and closing a block seems... burdensome.
Burdensome not due to typing an extra character or two,
but burdensome because the block and whitespace seem to make too big of a deal about something small, which at a
subconscious level causes mild dissonance and slows down the brain.
My two cents.
LATER UPDATE
I find myself trying to write code like this
# does not work
die "missing arg $_" unless $args{$_} for (qw(foo bar baz boop));
which feels more natural than opening a block (my dissonance theory)
# untested
for (qw(foo bar baz boop)) {
die "missing arg $_" unless $args{$_};
}
Similar is the use of
$_ to mean "this" or "that" in natural language.
All of these shortcut constructs are quicker and more like natural language -- and more difficult for someone entering the conversation late.
In reply to Re: All in one
by rkg
in thread All in one
by duff
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.