Because in ~s/(\w)(\s)(\w)/$1/eig (\w) matches one character, (\s) matches one character and (\w) matches one character. So in "Sam Adams" m A, gets matched and replaced with m.
What you more likely want is:
$name=~s/(\w*?)(\s).*/$1/eig;
In reply to Re: $1 $2 Weirdness?
by GrandFather
in thread $1 $2 Weirdness?
by apt_get
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |