in reply to How to use 2 files for calculating charges

This one may be over my head:
C:\Steve\Dev\PerlMonks\P-2013-08-13@1518-Time-Days-Discount-Computatio +n>doit1.pl Possible unintended interpolation of @ymd2 in string at C:\Steve\Dev\P +erlMonks\P-2013-08-13@1518-Time-Days-Discount-Computation\doit1.pl li +ne 33. Line 33: my @ymd1 = split ',',$dates[4] //= $prev_mth_end; Execution of C:\Steve\Dev\PerlMonks\P-2013-08-13@1518-Time-Days-Discou +nt-Computation\doit1.pl aborted due to compilation errors.
So my question is, what the heck does  //=  do?

Replies are listed 'Best First'.
Re^2: How to use 2 files for calculating charges
by Laurent_R (Canon) on Aug 13, 2013 at 22:02 UTC

    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>
      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