One last question. The construct //= I can see what it does, but I cannot find a reference?

// is called defined-OR. It essentially says: If the expression to the left is not defined, then execute the expression to the right.

Defined_OR_equals (my name for //=) says: if the variable to left is undefined, give it the value of the expression to the right. Great for initialing things when they may or may not have already been initialised.

It is the newer, better version of || and ||= which were used for the same things, but suffered from the flaw that they would overwrite defined but false values, like 0.

BTW: I'm with you on damning cutesy examples. They are next to useless. Actually, often worse than useless. Because you see them, they work without causing you to think too much. and leave you thinking you understand. It's not until you come to try and use the construct so demonstrated in a real-world situation, that you suddenly realise that you didn't learn a damn thing from the example.

And worse, because the example didn't cause you to think about what the construct actually does, it leaves a gaping hole in your mental arsenal of solutions, that causes you to jump through convoluted hoops trying to solve problems another way.

It's probably my biggest bugbear with the way Perl is used by many people. I came to realise very early on in my Perl journey, that every single built-in construct Perl provides, is there for a reason. To provide a ready, concise and efficient solution to a certain class of common problems.

Those people that insist on eschewing certain subsets of the full language on the grounds of spurious ideological philosophies, forever commit themselves to reinventing those eschewed subset in ever more laborious and convoluted ways.

Perl 5 ain't perfect by any means; but it's a damn sight closer to being complete than any other language I've used in anger. And I've used quite a few.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP an inspiration; A true Folk's Guy

In reply to Re^5: Joining separate data files to make one. by BrowserUk
in thread Joining separate data files to make one. by msexton

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



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.