in reply to regexp matching around a word

Don't use a regex; use split().
my @words = split /\s+$WANT\s+/, $text;

Now, you have the text on either side of "blue". Use my @other_words = split ' ', $foo; to get at the other words.

A regex is overkill and very unmaintainable. Keep it simple!


  • In general, if you think something isn't in Perl, try it out, because it usually is. :-)
  • "What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?"