in reply to Re: $1 $2 Weirdness?
in thread $1 $2 Weirdness?

What you more likely want is:
$name=~s/(\w*?)(\s).*/$1/eig;
I don't think so. yet more cargo cult regexing, huh? *sigh*

Let's strike all the unnecessary cruft.

Granted, the modifiers you inherited from the OP, but for the rest I see very little excuse.

IMO this is what the OP is after:

$name=~s/(\w+)(\s)(\w+)/$1/g;
or even
$name=~s/(\w+)\s\w+/$1/g;
though it would likely also do what he wants without the /g.

Replies are listed 'Best First'.
Re^3: $1 $2 Weirdness?
by GrandFather (Saint) on Jun 27, 2005 at 20:33 UTC

    Yes to all of that. I was cruising through the afternoon and spotted his immediate problem without actually engaging my brain and looking at the big picture. sigh. By the time I noticed it was too late to retract and others had pointed out the problems anyway.


    Perl is Huffman encoded by design.