Or, using m// instead of tr and the infamous =()= operator.
my $inp_row="per|l|mo|nks|ro|ck|s"; my $de = "|"; my $count =()= $inp_row =~ m/\Q$de/g; print "Delimeter is '$de', count is $count\n"; #Output: #Delimeter is '|', count is 6
In reply to Re: Regex - counting number of '|'
by FunkyMonk
in thread Regex - counting number of '|'
by perl_junkie
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |