$ perl -le ' $str = q{bit_of_a_pigs_ear}; print q{_ear} eq substr( $str, -3 ) ? q{Match found} : q{No match}; print q{_ear} eq substr( $str, -4 ) ? q{Match found} : q{No match};' No match Match found