in reply to Regex - counting number of '|'
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex - counting number of '|'
by perl_junkie (Acolyte) on Mar 18, 2008 at 00:14 UTC | |
by ww (Archbishop) on Mar 18, 2008 at 00:57 UTC | |
by ikegami (Patriarch) on Mar 18, 2008 at 03:10 UTC | |
by ikegami (Patriarch) on Mar 18, 2008 at 03:13 UTC | |
by poolpi (Hermit) on Mar 18, 2008 at 09:23 UTC |