#!/usr/bin/perl use Graph::Undirected; use warnings; use strict; package Graph::Base; # Instantiate my $G = new Graph::Undirected; open (IN, "Input.txt") || die $!; while (){ my @rxn=split/\#/,$_; # "$rxn[1]\n"; #debug my @cmp= split/\<=>/,$rxn[1]; #print"$cmp[0]\n"; # debug first element for reactants. my @rt=split/ \+ /,$cmp[0]; # split by space and '+'. if i don't put space b/n \+ i get bad formated output. my $x; #declaring $x b/c the use of strict wouldn't allow me to $x or my ($x)! for ($x=0; $x<=$#rt; $x++){ #print "$rt[$x]\n"; # debug prints the reactant compounds. } my @pd=split/\+/,$cmp[1]; my $y; for ($y=0; $y<=$#pd; $y++){ #print "$pd[$y]\n"; } $G = $G->add_edge($rt[$x], $pd[$y]); print "$G\n"; }