I was wondering when one should use s/// over tr/// when working with regular expressions in Perl?
I was wondering when one should use s/// over tr/// when working with regular
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
s///is for substitution:This will replace the first “abc” found in
$stringwith “123”.tr///is for transliteration:This will replace all occurrences of “a” within
$stringwith “1”, all occurrences of “b” with “2”, and all occurrences of “c” with “3”.