Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Newsgroups: comp.lang.perl Subject: Re: Matching parentheses Message-ID: <2890:Dec122:35:1290@kramden.acf.nyu.edu> Date: 1 Dec 90 22:35:12 GMT References: <12435:Nov3011:26:5990@kramden.acf.nyu.edu> <13858:Nov3016:23:4790@kramden.acf.nyu.edu> <1990Dec1.105725.28029@robobar.co.uk> Organization: IR Lines: 13 In article <1990Dec1.105725.28029@robobar.co.uk> ronald@robobar.co.uk (Ronald S H Khoo) writes: > brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes: > > #!/bin/sh > > ( echo '0'; echo '0'; fold -1 | sed 's,[^()],, > What's fold ? A program that wraps its input to a specific line length. fold -1 just puts a newline after each character. This is somewhat off the subject, though; I was just illustrating one way to code the parenthesis-counting technique. ---Dan Brought to you by Super Global Mega Corp .com