& => The ampersand (&). < => The less than sign (<). > => The greater than sign (>). ' => The single quote or apostrophe ('). " => The double quote (").
2. Perl替换程序
sub ConvertEntity { my ($origin)=@_; # < => The less than sign (<). # > => The greater than sign (>). # & => The ampersand (&). # ' => The single quote or apostrophe ('). # " => The double quote ("). $origin=~s/&/&/g; $origin=~s/</</g; $origin=~s/>/>/g; $origin=~s/'/'/g; $origin =~s/"/"/g; return($origin); } $string=qq{< and > and & and ' and "}; print ConvertEntity($string);