http://www.perlmonks.org?node_id=99979


in reply to Grouping output statements into one location during recursive operation

Is there any reason that traverse can't take a reference to your variable, for instance...
#!perl -w use strict; my $var; traverse($_, \$var) for @ARGV; print $var; sub traverse { my($node, $var)= @_; $$var .= $node . "\n"; traverse($node, $var) unless length $$var > 10; # to show it work recursively } __END__ varref a b c d a a a a a a b c d
(Sorry about the simplified traverse)