lex and yacc help desired

Tony Rems rembo at unisoft.UUCP
Tue Apr 30 11:25:54 AEST 1991


In article <1991Apr25.204908.21654 at odgate.odesta.com> mike at odgate.odesta.com (Mike J. Kelly) writes:
>In article <1991Apr23.164744.25927 at 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



More information about the Comp.unix.questions mailing list