the program ran as expected
but I did get this error:
Use of uninitialized value at instr_guts.pl line 39, <FILE2> chunk 2.
here's line 39:
39 if($replace =~ $1){
one thing I forgot to mention, at the end of every instructor bio in <BIOS>, I added
"XXX", so I could mark the end bio.
here's the sample output:
YES: C. J. S. WALLIA
1: Instructor: C. J. S. WALLIA
2: C. J. S. WALLIA
SUB: C. J. S. WALLIA, Ph.D., Stanford, has taught at UC Berkeley and St
anford. He has served as a
contract editor for several major publishing houses and high-technolog
y corporations, and is the author of two books on computer-assisted publishing. A
short story wri
ter, he edits and publishes an online literary magazine, IndiaStar Review of Books
(www.indiastar.
com).
XXX
>>> "R. Joseph Newton" <[EMAIL PROTECTED]> 03/13/03 18:25 PM >>>
Pam Derks wrote:
> thanks for help, here's my solution, any further comments are welcomed...
>
> thanks, Pam
Hi Pam,
What are the results from your test run? I foresee trouble beyond the first replaced
instrucor name. Let me know if I am off base here.
Joseph
> #!/usr/bin/perl -w
> use strict;
>
> #Purpose: replace Instructor: Name with bio from backmatter
>
> open(CAT, "catalog.txt") or die ("no IN file: $!");
> open(BIOS, "instructor.txt") or die ("no instructor file: $!");
> open(OUT, ">out") or die ("no out file: $!");
>
> select (OUT);
>
> get_name();
>
> sub get_name{
> my ($match, $line);
>
> while ($line = <CAT>){
> $match = '^Instructor:\s+([A-Z].+$)';
> if($line =~ /$match/){
> print("YES: $1\n");
> print("1: $line\n");
> replace_it($1);
> next;
> }
> else {
> print("NO: $line\n");
> }
> }
>
> } #end get_name
>
> sub replace_it{
> my $end = "XXX";
> my ($replace, @lines);
> print("2: $1\n");
>
> while ($replace = <BIOS>){
> if($replace =~ $1){
> push(@lines, $replace);
> last if($replace =~ $end)
> }
> }
> print("SUB: @lines\n");
> return;
> } #end replace_it
>
> close CAT;
> close BIOS;
> close OUT;
[snip]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]