@a = qw( food foot ); foreach (@a) { s/foo/bar/g } # @a is now qw( bard bart ) #### sub visit_breadth_first { my ($node, $visitor) = @_; # Initial value: my @to_visit = ($node); # Loop as long as @to_visit isn't empty: while (@to_visit) { # Remove an element: my $current = shift(@to_visit); # Maybe add some elements: push(@to_visit, @{$current->children()}); &$visitor($current); } } #### @a = map { ... transformation ... } @a; @a = grep { ... filter ... } @a; @a = sort { ... equiv test ... } @a;