in reply to Counting SubStrings, Style Question

Update:Corrected per jwkrahn's reply.

If scalar @count is greater than 2, then there must be more than one copy of substring in parent. If it is 2, there is just one. If it is zero one, it doesn't appear.

Update: To clarify per /msg, this is equivalent:

my $substring = 'xxx'; my $parent = 'xxx xxx xxx'; my @count = split($substring,$parent); my $total = scalar @count; print "there are $total $substring in $parent\n"; if( $total == 1 ) { print "None\n"; } elsif( $total == 2 ) { print "Unique\n" } else { print "Duplicates\n"; }

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"I'd rather go naked than blow up my ass"

Replies are listed 'Best First'.
Re^2: Counting SubStrings, Style Question
by jwkrahn (Abbot) on Mar 20, 2010 at 20:58 UTC

    And if it is 1, it is quantum entangled to hold all values at the same time?