Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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

by Laurent_R (Vicar)
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 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>


Comment on Re^2: How to use 2 files for calculating charges
Select or Download Code
Re^3: How to use 2 files for calculating charges
by BillKSmith (Chaplain) 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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1049349]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2014-07-30 02:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (229 votes), past polls