home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!europa.asd.contel.com!emory!sol.ctr.columbia.edu!eff!ckd
- From: ckd@eff.org (Christopher Davis)
- Subject: Re: using grep to extracting matching elements from an array
- In-Reply-To: kron@ueshiba.Corp.Sun.COM's message of 15 Dec 1992 23:28:24 GMT
- Message-ID: <CKD.92Dec16135228@loiosh.eff.org>
- Sender: usenet@eff.org (NNTP News Poster)
- Nntp-Posting-Host: loiosh.eff.org
- Organization: Electronic Frontier Foundation Tech Central
- References: <lisqgoINN14k@jethro.Corp.Sun.COM>
- Date: Wed, 16 Dec 1992 18:52:30 GMT
- Lines: 24
-
- KK> == Kenneth Kron <kron@ueshiba.Corp.Sun.COM>
-
- KK> I'd like to count the number of elements in an associative array whose
- KK> keys match an re.
-
- KK> @Group = grep("home", keys %LocalDisks) ;
- KK> print join(" ", @Group) ;
-
- KK> But group is always ALL the keys.
-
- "home" is a true value.
-
- /home/ is a regexp match for "home" on $_.
-
- KK> I know there are other ways to do this but what I want to know is what
- KK> don`t I understand about the GREP FUNCTION???
-
- It evaluates the first item in the list as an expression, and if it gets a
- true value, puts the current element into its return list.
- --
- Christopher K. Davis | ``Usenet seems to run much like the Kif (or,
- <ckd@eff.org> EFF #14 | for the TV generation, Klingon) high command.
- System Administrator, EFF | Whoever takes action and can be heard wins.''
- +1 617 864 0665 [CKD1] | --Peter da Silva <peter@ferranti.com>
-