Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2016-10-27 10:11 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (358 votes). Check out past polls.