Hi, I've been thinking about this for quite some time now. Suppose I have a text file ("mypet.log" that contains:
dog pig cat Then I have another text file and I want to read it line by line and extract each line that has those contained in the first file. Sort of like running while inside while. "myallpetlogs" contains: blabla dog blah blabla cat blah blabla dog blah blabla pig blah blabla cat blah blabla pig blah Now, the goal is to have 3 files which contains all extracted lines in "myallpetlogs" 1. dogs.logs 2. cat.logs 3. pig.logs How do I assign some variable to what was returned by while loop? Perhaps the above goal should be written like this: open MYPETS, '<', or die $! open PETLOGS, '<', or die $! whileeach my $pets (<MYPETS>){ whileeach my $petlogs (<PETLOGS>){ "read each line extracting $pets and putting it in $pet.log" "and after reading the entire PETLOGS again, go to the next pet and... " read the PETLOGS all over again and extract the next pet??? Oh my, I'm lost.. } } Any idea? Thanks ____________________________________________________________________________________ Looking for earth-friendly autos? Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center. http://autos.yahoo.com/green_center/