Hi Folks,

[I sent this post this morning but it doesn't look like made it.  So I'm 
resending it!]

I've been struggling with this for a couple of hours this morning and it 
seems like I'll need some help from the pros.
I have a long file consisting of document numbers.  I would like to 
insert sequentially a number into records saved in another file I am data 
munging through a while loop.  The problem I am faced with is
how to instruct the code to insert a single array element and remember 
where it left off.  A flag of some sort.  For instance,
during the first run, it'll get no 000030004 and insert it in record A, 
then no 000030067 for record B, etc. I believe I have to use splice 
(splice @array (0,1)) to achieve this; or do I?  My code inserts all the 
record numbers during the while loop. 

I am including a simplified version of my code here for your review.  The 
defective code is commented. Your help is very much appreciated.  

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 
use strict;
use Text::Wrap;

my @doc_num= qw (000030004 000030067 000030068 000030079 000030148 
000030294 000030319 000030454 000031100 000031125 000031131 000031140 
000031410);
$doc_num_ref = \@doc_num;

my($author,$title,$publisher,$notes,$abstract)=split /\|/,$_;

open (IN,"<l:/intext.txt") or warn "Cannot find specified file: $!\n";
open (OUT,">c:/outtxt.txt") or warn "Cannot create specified file: $!\n";

select (OUT);
while (<IN>){
    
   print "*** DOCUMENT BOUNDARY ***\n";
   #&doc_num;
    if ($author =~ (/.$/)){
    &multi_authors;
   }
    if ($title =~ (/.$/)){
   print "..TI:\n",wrap("     ","","$title"),"\n";
   } 
    if ($publisher =~ (/.$/)){
   print "..PU:\n",wrap("     ","","$publisher"),"\n";
   }    
    if ($notes =~ (/.$/)){
   print "..NT:\n",wrap("     ","","$notes"),"\n";
   }
    if ($abstract =~ (/.$/)){
   print "..ABST:\n",wrap("     ","","$abstract");
   }
}
close (IN);
close (OUT);

sub multi_authors{
  $author =~ s/;\s+/;/mg;
  @authors = split /;/,$author;
      foreach $author(@authors){
          print "..AU:\n",wrap("     ","","$author"),"\n";
      }

}




#sub doc_num{

      #foreach $doc_num (@$doc_num) {
      #    print "..Document-Number:     $doc_num\n";
      #}
   #}


__END__
_______________________________________________________
The American Occupational Therapy Foundation (AOTF)
Creating Opportunities through Research and Education
http://www.aotf.org
301.652.2682



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to