From merlyn at stonehenge.com Sun Jul 1 19:27:10 2018 From: merlyn at stonehenge.com (Randal L. Schwartz) Date: Sun, 01 Jul 2018 19:27:10 -0700 Subject: [Chicago-talk] Could someone explain this In-Reply-To: (Joel Limardo's message of "Thu, 28 Jun 2018 12:56:09 -0500") References: <20180628174735.4B69411F9F2@xx1.develooper.com> Message-ID: <864lhi74ox.fsf@red.stonehenge.com> >>>>> "Joel" == Joel Limardo writes: Joel> The match with the /g operator says find all so and that is in Joel> parentheses so my guess is that produces a list containing all of Joel> the matches. That gets assigned to an anonymous array which in Joel> turn is being assigned to a scalar which, as you should know from Joel> rudimentary Perl lessons, results in the number of elements in the Joel> array to be returned. Not quite right. There's no assignment to an anonymous array. It's just that "list assignment in scalar context" provides a list context to the right side, and then counts the items it *would* have put into something on the left side, and returns that as a scalar. It's similar to how: if (my ($x, $y) = m{(.*)/(.*)}) { ... } evaluates that list assignment in a scalar (boolean) context, which returns 0 if it doesn't match, or 2 if it does. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 Perl/Unix/Dart consulting, Technical writing, Comedy, etc. etc. Still trying to think of something clever for the fourth line of this .sig