in reply to $1 $2 Weirdness?
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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: $1 $2 Weirdness?
by bart (Canon) on Jun 27, 2005 at 08:40 UTC | |
by GrandFather (Saint) on Jun 27, 2005 at 20:33 UTC | |
|
Re^2: $1 $2 Weirdness?
by apt_get (Acolyte) on Jun 27, 2005 at 00:18 UTC |