Graph::BFS (breadth-first search) looks like exactly what you need. Tables are vertices, foreign keys are edges (unfortunately, at a quick glance it does not look like you can name edges). Look at its superclass Graph::Traversal for the documentation, which is sparse even there. You'll need to create the graph using Graph::Undirected (again, look at the documentation in the superclass Graph::Base). Here's the Graph package.
Comment on Re: Re: Path computation for SQL generation
I'm reading through the source (not that I understand much) for Graph. How on earth do I ask the following question:
Is there a path from X to Y and, if there is, give me the elements I traverse.
Update: After playing around a bunch, I found the following:
my $SSSP = $graph->SSSP_Dijkstra($start);
my %attrs = $graph->get_attributes($end);
my $path = $attrs{path};
die "No path found\n" if !defined $path;
print "Path: @$path\n";