I found an example of some Perl code I needed, but it had something in it that I didn’t recognise.
my $i //= '08';
I can’t find any reference to this anywhere! It appears to be the same as:
my $i = '08';
Am I missing something?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
//=operator is the assignment operator version of the//or ‘logical defined-or’ operator.In the context of a
myvariable declaration, the variable is initially undefined so it is equivalent to assignment (and would be better written asmy $i = '08';). In general, though,is a shorthand for:
It is documented in the Perl operators (
perldoc perlop) in two places (tersely under the assignment operators section, and in full in the section on ‘logical defined-or’). It was added in Perl 5.10.0.