while (<>) { chomp; (@row) = split(/ /,$_); foreach $item (@row) { ($node,$value) = split(/->/,$item,2); $graph{$node} = $value; } sub depth { return max map { $_ and 1 + depth($graph{$_}) } @_; shift @_ } print depth(keys %graph); print "\n"; @row = (); $graph = "" }