in reply to Re^4: Joining separate data files to make one.
in thread Joining separate data files to make one.

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