http://www.perlmonks.org?node_id=989300


in reply to Re^2: Paths::Graph use
in thread Paths::Graph use

Why not structure your data as correct perl, then just read it in and eval it?
# data file ( # Quoting the dotted quads since => will not quote # those correctly '10.0.0.128' => { '10.0.0.129'=>3, '10.0.0.129'=>4, '10.0.0.130'=>3, '10.0.0.131'=>2, '10.0.0.132'=>1, '10.0.0.133'=>1, '10.0.0.134'=>2, '10.0.0.135'=>4, '10.0.0.136'=>1, '10.0.0.137'=>4, '10.0.0.138'=>3 }, '10.0.0.129' => { '10.0.0.128'=>3, '10.0.0.130'=>1, '10.0.0.131'=>2, '10.0.0.132'=>1, '10.0.0.133'=>2, '10.0.0.134'=>1, '10.0.0.135'=>2, '10.0.0.136'=>3, # the > was missing on this line... '10.0.0.137'=>3, '10.0.0.138'=>4 }, );
Now your reading code can simply be:
my $x=join "",<FILE>; my %graph = eval $x;

Mike