<p dir="ltr">The match with the /g operator says find all so and that is in parentheses so my guess is that produces a list containing all of the matches. That gets assigned to an anonymous array which in turn is being assigned to a scalar which, as you should know from rudimentary Perl lessons, results in the number of elements in the array to be returned.</p>
<p dir="ltr">When curious to know what long, somewhat tricky Perl lines of code are doing you can just split them up into mulfiple instructions and then use the debugger to figure out what is being passed around.</p>
<div class="gmail_extra"><br><div class="gmail_quote">On Jun 28, 2018 12:47 PM, "Jim Jacobus" <<a href="mailto:JJacobus@ponyx.com">JJacobus@ponyx.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
I'm embarrassed to ask this, but I'd like to understand this piece of code.<br>
<br>
I want to find out how many times a certain substring appears in the string ($block). $block is a very long string that is part of an XML file.<br>
I found this when rooting around for an example:<br>
<br>
my $count = () = ( $block =~ m/\<category\>/g);<br>
<br>
It does work. $count gives me the number of times the substring appears in $block.<br>
However, I don't undstand how this works. What is "= () =" mean.<br>
<br>
Jim<br>
______________________________<wbr>_________________<br>
Chicago-talk mailing list<br>
<a href="mailto:Chicago-talk@pm.org" target="_blank">Chicago-talk@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/chicago-talk" rel="noreferrer" target="_blank">http://mail.pm.org/mailman/lis<wbr>tinfo/chicago-talk</a><br>
</blockquote></div></div>