SPUG: Grep syntax

Yitzchak Scott-Thoennes sthoenna at efn.org
Sat Jun 16 22:45:55 PDT 2007

On Fri, June 15, 2007 11:32 pm, Bill Campbell wrote:
> My original request was (a) to try to figure out why somebody
> would use grep in a manner that wasn't about pattern recognition, but used
> for looping, and (b) I think I said that map would be a more logical
> choice for that.

grep, used in the normal way, is about list selection.  Pattern
recognition is one common way of doing that selection, but
seeing grep used in other ways shouldn't be a surprise.
For instance, one way of finding the keys two hashes have
in common is:

  @common_keys = grep exists $hash2{$_}, keys %hash1;

More information about the spug-list mailing list