Uncaught exception from user code: Can't call method "walk" on unblessed reference at treewalk.pl line 28. main::walk('ARRAY(0x15b220)') called at treewalk.pl line 34 #### #!/bin/env perl use strict; use warnings; use diagnostics; my $tree = [ "Accomplishments in the past week" => 'accomplishments.txt', "Plans for the next week" => [ General => 'plans.txt', Vacations => 'vacations.txt', Classes => 'classes.txt' ], "Outstanding issues" => 'issues.txt' ]; sub walk { my $t = shift ; while (my ($key, $val) = splice @$t, 0, 2) { if (!ref($val)) { print "$key => $val\n"; } else { walk $val; ##### PROBLEM LINE } } } walk $tree;