<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def perform_bulk_pubmed_query(self):
 """ If 'bulk_pubmed_query' contains any content, perform a bulk PubMed query, add the publications to the publication set, and save. """

        if self.bulk_pubmed_query:
            failed_queries = []
            pmid_list = re.findall(r'(\d+)(?:[\s,]+|$)', self.bulk_pubmed_query)

            for pmid in pmid_list:
                try:
                    p, created = Publication.objects.get_or_create(pmid=pmid)
                except:
                    failed_queries.append(pmid)
                else:
                    self.publications.add(p.id)

            if failed_queries:
                failed_queries.sort(key=int)
                self.bulk_pubmed_query = 'FAILED QUERIES: {}'.format(', '.join(failed_queries))
            else:
                self.bulk_pubmed_query = ''