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


in reply to Re^4: How to save first two columns of an array into another array
in thread How to save first two columns of an array into another array

I can’t find any module named Graph::Subgraph on or meta::cpan. When I comment out the line use Graph::Subgraph; and run the code, I get the error you describe. The strict pragma is telling you that the syntax is wrong, so removing strict here would merely make the problem harder to identify!

I’m not sure what the code in this for loop is meant to achieve, but perhaps something as simple as

for my $src (keys %h) { $g->add_edge($src, $h{$src}); }

will do what you want? If so, that leads to another, similar, "strict refs" error in the line $allgraphs[-1]{$node} = [ @{ $h{$node} } ];. But since I don’t understand what this final for loop is doing, I’m afraid I can’t offer any help here.  :-(

Tip: In future, please show the minimum code that demonstrates the problem, and explain exactly what the code is intended to do. Comment the code liberally. See How do I post a question effectively?.

Update: Just discovered, this issue has been re-addressed in Finding connected components in a graph..

Athanasius <°(((><contra mundum