in reply to Re^2: IT's not counting...
in thread IT's not counting...
As jwkrahn had pointed out, the string is not clobbered by his code. You need to supply the d flag to actually delete the characters.
knoppix@Microknoppix:~$ perl -E ' > $str = q{3 * (4 + 5) / (6 - 7)}; > say $str; > $lb = $str =~ tr/(//; > $rb = $str =~ tr/)//; > say qq{left : $lb}; > say qq{right: $rb}; > say $str; > $dig = $str =~ tr/0-9//d; > say qq{digit: $dig}; > say $str;' 3 * (4 + 5) / (6 - 7) left : 2 right: 2 3 * (4 + 5) / (6 - 7) digit: 5 * ( + ) / ( - ) knoppix@Microknoppix:~$
I hope this is helpful.
Cheers,
JohnGG
|
|---|