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 perl5db.pl 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 (Monsignor) 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;
    Bill