Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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.


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

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (1)
As of 2023-09-28 20:41 GMT
Find Nodes?
    Voting Booth?

    No recent polls found