> Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm > Date: Wed, 8 Jan 2003 10:45:37 -0600 > From: Jonathan Scott Duff <[EMAIL PROTECTED]> > Cc: [EMAIL PROTECTED] > Reply-To: [EMAIL PROTECTED] > Mail-Followup-To: frederic fabbro <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] > Content-Disposition: inline > X-SMTPD: qpsmtpd/0.20, http://develooper.com/code/qpsmtpd/ > > On Wed, Jan 08, 2003 at 05:14:06PM +0100, frederic fabbro wrote: > > I'm not even sure how that would parse, though that: > > @keep <~ grep /good/ <~ @list ~> grep /bad!/ ~> @throw; > > would go like: > > ( @keep <~ grep /good/ <~ @list ) ~> grep /bad!/ ~> @throw; > > > > which is probably not what i wanted... > > Oh, then we just need a syntax to split the streams. ... I know! > > @list ~| grep /bad!/ ~> @throw ~| grep /good/ ~> @keep; > > which, of course, could be written in the more readable form: > > @list ~| grep /bad!/ ~> @throw > ~| grep /good/ ~> @keep;
Spookily, this quantumish operation can be achieved with Perl's quantumish operators. @list ~> (grep /bad!/ ~> @throw) | (grep /good/ ~> @keep); I'd actually think I'd be happier if that didn't work. Fortunately, I don't think it does (how do you put an argument on the end of a "|" expression?)). What we really need is a beam-split operator: @list ~> (-grep /bad!/ ~|~ grep /good/) ~> @result; Then @result would contain all things bad or good, but not both, because they interfere! :) > And that, of course, leads us to sort of "unzip" were mutual exclusion > is not a requisite: > > @list ~| grep length == 1 ~> @onecharthings > ~| grep [0..29] ~> @numberslessthan30 > ~| grep /^\w+$/ ~> @words > ~| grep $_%2==0 ~> @evennumbers; I'm not going even to try this one. > :-) (-: Luke