in reply to Re^2: Regex - counting number of '|'
in thread Regex - counting number of '|'
Oh and the tr/// line
my $count = (eval "\$inp_row =~ tr/$de//");
has a problem too. The contents of $de aren't properly converted from text to a tr/// search list. It happens to work for "|", but it won't work for arbitrary seperator characters which seems to be your goal. Fixed:
my $count = (eval "\$inp_row =~ tr/\Q$de\E//");
The following is much simpler, though:
my $count =()= $inp_row =~ /\Q$de\E/g;
|
|---|