Xref: utzoo comp.lang.c:38850 comp.unix.questions:30865 comp.unix.wizards:25248 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!pacbell.com!att!ucbvax!unisoft!rembo From: rembo@unisoft.UUCP (Tony Rems) Newsgroups: comp.lang.c,comp.unix.questions,comp.unix.wizards Subject: Re: lex and yacc help desired Message-ID: <3499@unisoft.UUCP> Date: 30 Apr 91 01:25:54 GMT References: <1991Apr23.164744.25927@mnemosyne.cs.du.edu> <1991Apr25.204908.21654@odgate.odesta.com> Reply-To: rembo@unisoft.UUCP (Tony Rems) Organization: UniSoft Corporation -- UNIX R Us. Lines: 24 In article <1991Apr25.204908.21654@odgate.odesta.com> mike@odgate.odesta.com (Mike J. Kelly) writes: >In article <1991Apr23.164744.25927@mnemosyne.cs.du.edu> allen wade writes: >>I am fairly new to Lex and Yacc and I am tring to develop a >>language definition for a small report processer. >> My input lines will generally look like this: >> >>|MEDINA|ANTOINIO|01/14/62|M|(312)778-2540|60629|GARFIELD|LAREN|GP|DC101A| >> > >You could use Yacc to parse this, but it's really overkill. scanf(3) >would work as well, or at worst, just read the line into a string and >use the string package to separate out the components; look at strtok(3) >and strchr(3). > Actually, this seems ideally suited to awk or, preferably perl :). You could split these fields up with one split command in perl. Then to really use perl right, you could stick it into an associative array (I'm sure Mr. Wall is smiling), and you can do any sort of operations on it you'd like. Try perl today! -Tony