if (my @matches = $line =~ m/\[\[(?:[^\]]+?\|)?([^\]]+?)\]\]/) { print(INDEX $_."\n") foreach @matches; INDEX->flush(); } if (my @matches = $line =~ m/{{t\|[a-z]{2,3}\|([^\|]+?)(?:\|[^}]+?)*}}/) { print(INDEX $_."\n") foreach @matches; INDEX->flush(); }