[Chicago-talk] Could someone explain this

Shlomi Fish shlomif at shlomifish.org
Thu Jun 28 11:00:32 PDT 2018


Hi Jim,

On Thu, 28 Jun 2018 12:21:25 -0500
Jim Jacobus <JJacobus at PonyX.com> wrote:

> Hi,
> I'm embarrassed to ask this, but I'd like to understand this piece of code.
> 
> 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.
> I found this when rooting around for an example:
> 
> my $count = () = ( $block =~ m/\<category\>/g);
> 
> It does work. $count gives me the number of times the substring 
> appears in $block.
> However, I don't undstand how this works. What is "= () =" mean.
> 

see
https://metacpan.org/pod/distribution/perlsecret/lib/perlsecret.pod#Goatse .
Also note regarding XML that http://perl-begin.org/uses/text-parsing/ - do not
use regexes for that.

> Jim
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk



-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Parody of "The Fountainhead" - http://shlom.in/towtf

Sisko: Q: would it be OK if my crew brought along their phasers with them?

Q: Of course. They can also bring some photon torpedoes if they wish. None of
them will work, but I don’t mind them taking them.

Please reply to list if it's a mailing list post - http://shlom.in/reply .


More information about the Chicago-talk mailing list