This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Aug 3rd, 2012  |  syntax: Perl  |  size: 0.38 KB  |  views: 3  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. open  fh, "<", "b.txt" or die $!;
  2. open  fh1, "<", "a.txt" or die $!;
  3.  
  4. my $i = 0;
  5. while(my $item1 = <fh>)
  6. {
  7.     open fh2, ">>", "a$i.txt" or die $!;
  8.     while(my $item2 = <fh1>)
  9.     {
  10.         if($item1 =~ m/$item2/i)
  11.         {
  12.             print fh2 $item1, $/;
  13.             print fh2 <fh>;
  14.         }
  15.     }
  16.     close fh2;
  17.    
  18.     seek fh1, 0, 0;
  19. }
  20.  
  21. close fh;
  22. close fh1;
clone this paste RAW Paste Data