I have about 900 instructors and file2 is NOT in the same order as file1... I'll give the key/value approach
thanks, Pam >>> "Wagner, David --- Senior Programmer Analyst --- WGO" <[EMAIL PROTECTED]> 03/13/03 >>> 08:37 AM >>> Pam, Using the +< for the re-writes won't work. I believe they need to be the same size for what you want to replace. Since you are using a name and then replacing with the name plus bio, you will need a third file to write to. How many instructors do you have? Unless file2 is the same order as file1, you will have to read through the file constantly(opening and closing). I just completed one set of testing of about 800K keys of 12 bytes each going against a file of about 300k. Total time was less than a minute to process. You might try loading the the instructors as the key and the bio as data, then read file1 and when you hit an instructor, then use that as the key to access your data and write out the info. Wags ;) Pam Derks wrote: > Hi all, > > > In FILE1 I want to replace all the lines containing: > Instructor: [A-Z].+ > > with the complete biography for each instructor in FILE2 > > or > replace this text in FILE1 > Instructor: GENE ABBOTT > > with this text from FILE2 > GENE ABBOTT, M.A., has worked in vocational and adult education since > 1973. He has been department chair, lead teacher, mentor, and > consultant, and is program manager for the Marin County Regional > Occupational Program. > > > Problem: > 1 .I'm getting an infinite loop on the instructors' names in > replace_it() > 2. and @replace never gets the instructors' bios > > > any clues would be appreciated, > > thanks in advance, Pam > > > > > ---------------------------------------------------- > code thus far > > #!/usr/bin/perl -w > use strict; > > #Purpose: replace Instructor: Name with bio from backmatter > > open(FILE1, "+<write.txt") or die ("no IN file: $!"); > open(FILE2, "instructor.txt") or die ("no instructor file: $!"); > > my @bios = (); > my $bio; > > get_name(); > > sub get_name{ > my ($match, $line); > > while ($line = <FILE1>){ > $match = '^Instructor:\s+([A-Z].+$)'; > foreach ($line =~ /$match/){ > push(@bios, $1); > } > } > replace_it([EMAIL PROTECTED]); > > } #end get_name > > > sub replace_it{ > my ($aref, $line, $text); > my @replace = (); > $aref = [EMAIL PROTECTED]; > > > > while($line = <FILE2>){ > foreach $bio(@$aref){ > print("$bio\n"); > #not working ######################### > if (/$bio/ .. /\.^[A-Z]/){ > push(@replace, $line); > } > } > > } > print("@replace\n"); > } #end replace_it > > > > close FILE1; > close FILE2; > > ------------------------------ > > output: > > C. J. S. WALLIA > Use of uninitializd value at try4 line 36, <FILE2> chunk 1. > MICHAEL LEE ZEITSOFF > Use of uninitialized value at try4 line 36, <FILE2> chunk 1. > > > > > ----------------------------------------------------- > Sample: FILE1 > > Practical Grammar for > Writers and Editors > X155 (1 semester unit in English) > Working editors and writers often find that they need to improve > their command of English grammar. This course concentrates on grammar > as an effective technique for using language to clarify thought. > Basic concepts are analyzed, with logic as the focus. Section 1: > Wednesdays in Berkeley Instructor: GENE ABBOTT > n 8 evenings > n July 2 to Aug. 20: Wed., 6:30-9:30 pm > n Berkeley: Room 105, UC Berkeley Extension International Center, > 2222 Harold Way n $325 (EDP 025122) > > Section 2: Online > Instructor: MICHAEL LEE ZEITSOFF > n Online course: Internet access required > n Enroll anytime: You have 6 months to complete > n $350, plus $50 online resource fee (EDP 017830) > n For information and to enroll (510) > 642-4124 > > Editorial Workshop I: > Introduction to Copyediting > X405 (2 semester units in Journalism) > course description blah blah blah.... > Instructor: DAVID COUZENS > n 8 evenings and 2 Saturdays > n June 3 to July 22: Tues., 6:30-9:30 pm; also > June 21 and July 12: Sat., 9 am-noon > n San Francisco: 209 Richardson Hall, > San Francisco Center, 55 Laguna St. > n $395 (EDP 025031) > > > sample FILE2 > > VIRGINIA ABASCAL, M.A., is a freelance director and has directed more > than 40 plays in theaters including Theatreworks, San Jose State > Company, Asian American Theatre Company, Speakeasy Theatre, and > Theatre Artists of Marin, where she was resident director for eight > years, working with new plays. She has won Critics Choice, Bay Area > Critics Circle, and Dean Goodman production awards. GENE ABBOTT, > M.A., has worked in vocational and adult education since 1973. He has > been department chair, lead teacher, mentor, and consultant, and is > program manager for the Marin County Regional OccupationalProgram. He > has taught in adult education, community college, and ROP. He has > lectured throughout California on the topic of "Thinking > Curriculum in Technical Education." ********************************************************** This message contains information that is confidential and proprietary to FedEx Freight or its affiliates. It is intended only for the recipient named and for the express purpose(s) described therein. Any other use is prohibited. **************************************************************** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]