#!/usr/bin/env perl -l
use strict;
use warnings;
use autodie;
use Graph::Undirected;
my $graph = Graph::Undirected::->new();
open my $input_fh, '<', './pm_graph_undirected.txt';
while (<$input_fh>) {
my ($x, $y) = /^\w+[#]([^<]+)\s+<=>\s+(.*)$/;
$graph = $graph->add_edge(split /,/) for glob join ',' =>
map { '{' . join(',' => split /[+ ]+/ => $_) . '}' } ($x, $y);
}
print $graph;
####
$ cat pm_graph_undirected.txt
R1#C01+ C02 <=> C03 + C04
R2#C01 + C04 + C05 <=> C07 + C08 + C09
####
$ pm_graph_undirected.pl
C01=C03,C01=C04,C01=C07,C01=C08,C01=C09,C02=C03,C02=C04,C04=C07,C04=C08,C04=C09,C05=C07,C05=C08,C05=C09