Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: ||= (poorly documented?)

by Anonymous Monk
on Jul 09, 2012 at 06:21 UTC ( #980655=note: print w/replies, xml ) Need Help??

in reply to ||= (poorly documented?)

This is really poorly documented...

Yes, if you only go by, looking only for |=", it is poorly documented.

Replies are listed 'Best First'.
Re^2: ||= (poorly documented?)
by frozenwithjoy (Priest) on Jul 09, 2012 at 06:31 UTC
    To be fair, some things are a pain in the ass to google properly (especially if you aren't familiar with the topic in the first place). Also, documentation always makes more sense when you already know the topic. :P
      This actually is easily googleable... if you're deep enough into the Perl culture. Try searching for it under the name "orcish maneuver", which will explain not only what the operator is but also exactly how it's being used in this case. (Link is to duckduckgo's first result, which just happens to also be on PerlMonks.)

      Also note that, because of the distinction between truthiness and definedness mentioned in previous replies, you're going to want to use //= instead of ||= in the vast majority of cases unless your code needs to support pre-5.10 versions of Perl.

        If you are "deep enough in the Perl culture" to know to google "orcish maneuver", you probably don't need to look it up. On the other hand, if all you know to google is "||=", you're screwed unless you think to try "double pipe equals".
      To be fair ...

      Teach a man how to find answers and you teach him for life.
      Answer his questions for him and you get Perlmonks XP.

        You got me, the only reason I'm on here is to accumulate XP so I can get more spells and a larger HP pool next level.

        Seriously though, I think the OP did a decent job trying to figure things out before posting. S/he read the obvious doc, did some troubleshooting, and had a nearly correct understanding of the ||= operator, but was unsure and needed confirmation and a little guidance. I think the OP's main issue is that the reader of perlop needs to extrapolate some of the function of ||= from the examples for += and the OP may have missed that. Regarding // vs ||, even some of the people answering had some confusion.

        OK, that's my two cents. Now I'm off to Reddit, where the votes actually matter!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://980655]
and God said, "Let Newton be!"...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2018-03-20 20:08 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (259 votes). Check out past polls.