in reply to Grouping output statements into one location during recursive operation
Use a global variable our @results; and replace every print with push @results, "<".$node->somefun.">"; I hope this does what you meant.
-- Hofmator