#!/bin/perl; use strict; use warnings; use List::Util qw/max/; my %graph; 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 = "" } #### Global symbol "@row" requires explicit package name at count_PT.prl line 11. Global symbol "$item" requires explicit package name at count_PT.prl line 12.