Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re^2: How to use 2 files for calculating charges

by Laurent_R (Abbot)
on Aug 13, 2013 at 22:02 UTC ( #1049349=note: print w/replies, xml ) Need Help??

in reply to Re: How to use 2 files for calculating charges
in thread How to use 2 files for calculating charges

So my question is, what the heck does //= do?

This is the relatively new "defined or" operator

$a //= $b;

means that $a is unchanged if it is defined, and is assigned to $b if not defined.

At least, that's my understanding, I have never used it, but the following test under the Perl debugger seems to confirm it:

$ perl -de 42 Loading DB routines from version 1.33 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(-e:1): 42 DB<1> $a //=5; DB<2> p $a 5 DB<3> $a //=6; DB<4> p $a 5 DB<5>

Replies are listed 'Best First'.
Re^3: How to use 2 files for calculating charges
by BillKSmith (Priest) on Aug 14, 2013 at 04:13 UTC
    This feature added in perl v5.10.0 Refer perl5100delta:
    and the statement $c //= $d; can now be used instead of $c = $d unless defined $c;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1049349]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2017-02-22 04:39 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (324 votes). Check out past polls.