lanx@nc10-ubuntu:~$ perl -e ' $sub = "xxx"; $par = "xxx xxx xxx"; $count = () = $par =~ /$sub/g; $count == 0 ? print "none" : $count == 1 ? print "unique" : print "duplicates"; ' duplicates
HTH! :)
Cheers Rolf
UPDATE: beautified code ;)
see here how to avoid the ternary cascade.
In reply to Re: Counting SubStrings, Style Question
by LanX
in thread Counting SubStrings, Style Question
by se@n
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |