in reply to Re^3: Cool example of list assignment usage
in thread Cool example of list assignment usage

I can't guess what =()= is supposed to do.

How strange, it is a very common Perl idiom:

my $count =()= /$regex/g
Maybe this is similar to this regex construct, which I use even though it looks very non-intuitive to me:
my ($match) = ($string =~ m/regex/);

Why so? Incidentally I think you want a /g in the match, and the second pair of parens is clearly unnecessary.

Update: did a Super Search and added link to the explanation of the idiom

Replies are listed 'Best First'.
Re^5: Cool example of list assignment usage
by perrin (Chancellor) on Jul 23, 2007 at 17:56 UTC

    I don't think =()= is very common. I've seen a lot of perl code and never seen this idiom. Is it in one of the books or man pages?

    You're correct about the missing /g. The extra parentheses are there to make it easier for me to read, although perl doesn't need them.

      You're correct about the missing /g. The extra parentheses are there to make it easier for me to read, although perl doesn't need them.

      You see? Different people have different preferences and tastes, unnecessary parens tend to make stuff more difficult for me to read in say 99% of cases.