in reply to regexp to match repeated charater

If I have understood the question correctly, you're looking for the spaceship goats.cx operator.

#! /usr/bin/perl use strict; use warnings; my $str = 'It was an intelligent stori'; for my $word (split / /, $str) { my $nr =()= $word =~ /(i)/gi; if ($nr > 0) { print "$word has $nr $1\n"; } }

(No, there's not really such an operator, it's more an emergent effect of forcing a global match's list context into scalar context by assigning the result to (), the empty list).

• another intruder with the mooring in the heart of the Perl

Replies are listed 'Best First'.
Re^2: regexp to match repeated charater
by Codon (Friar) on Aug 28, 2007 at 19:52 UTC
    Your first sentence confused me. The "spaceship" operator is <=> (numeric comparison operator). I couldn't figure out what you were going to do with that. Then, after glancing at the code, reading your note at the bottom, wondering "What do you mean, there really isn't a spaceship operaton?", looking back at the code more closely, I saw you meant =()= to be the "spaceship" operator. Same name, different usage.

    Ivan Heffner
    Sr. Software Engineer
    WhitePages.com, Inc.

      Oops. You are quite right. I did of course mean the infamous goats.cx operator. I leave it to your imagination to figure out why =()= was so named. I shall amend the parent node accordingly. Thanks.

      • another intruder with the mooring in the heart of the Perl