/d stands for delete .
It is quite unusual to make tr so, because it is confusing.
tr/az//d
will remove all az characters.
tr/az/b/
transliterates all az characters to b .
What happens here, although there is - because your transliteration does not display the same number of characters on each side - everything that is not displayed is deleted.
So what you do is:
tr/bz//d; tr/a/b/;
eg. transliterating all a to b and then deleting anything else (except spaces and dots).
To illustrate:
use strict; use warnings; my $string = 'the cat sat on the mat.'; $string =~ tr/the/xyz/d; print "$string\n";
Warns:
Useless use of /d modifier in transliteration operator at line 5.
and prints:
xyz cax sax on xyz max.
If you change this to:
#!/usr/bin/perl use strict; use warnings; my $string = 'the cat sat on the mat.'; $string =~ tr/the/xy/d; print "$string\n";
Instead, you will get:
xy cax sax on xy max.
And thus: t β x and h β y . e simply deleted.
source share