$string = 'my name is mister smith';
if($string =~ /(mr\.|mister (\w+))/){
# if the string contains either 'mr.' or
# 'mister', then a space, then some word chars
# matching for instance 'mister jones' but not
# 'hey mister!'
print "surname is $2";
# $1 contains the whole thing, $2 just the surname
}
####
$text='Learning Perl? http://www.perlmonks.org/ is the place';
$text =~ s!(http://\S+)
(\s+<([^>]+)>)?
!
defined($3)?
qq($3):
qq($1)
!gex;
print $text;
####
($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss')
=~y~b-v~a-z~s; print