轉換類似於 Perl 中的替換原則,但與替換不同,轉換(或音譯)不使用正則表示式進行搜尋和替換值。轉換運算子是 - tr/SEARCHLIST/REPLACEMENTLIST/cds y/SEARCHLIST/REPLACEMENTLIST/cds 轉換將 SEARCHLIST 中的所有字元都替換為 REPLACEMENTLIST 中相應的字元。例如,使用我們在本章中一直在使用的字串“The cat sat on the mat.” - 示例 即時演示 #/user/bin/perl $string = 'The cat sat on the mat'; $string =~ tr/a/o/; print "$string"; 當上述程式執行時,它會產生以下結果 - The cot sot on the mot. 標準 Perl ... 閱讀更多