#!/usr/bin/perl use strict; use warnings; use diagnostics; use Graph; use Graph::Traversal; our %net=(); our %RHash; our %ConnHash; our %ToGraphHash; open(IHF,"<", "sample_file"); while() { if (/D_NET/) { my ($DNet, $netMap, $netCap) = split; $net{'NET'} = $netMap; }elsif(/CONN/../CAP/) { next if (/CONN/); next if (/CAP/); next if(/^\n/); my ($PortType, $PortName, $PortDir) = split; $ConnHash{$net{'NET'}}{$PortName} = [$PortName,$PortDir]; }elsif(/^\*RES/../^\*END/) { next if (/^\*RES/); next if (/^\*END/); next if (/^\n/); next if (/^\s+\n$/); chomp; my @RArr = split; $RHash{$net{'NET'}}{$RArr[0]} = [ $RArr[1], $RArr[2], $RArr[3] ]; } } foreach my $n (sort keys %RHash) { my $x = $n; $x = Graph->new; foreach my $k (sort keys %{$RHash{$n}}) { $x->add_weighted_edge(@{$RHash{$n}{$k}}); } print $x; }