in reply to Haskell-style list folding

This is one of the places where prototypes would come in handy. foldl (&$@) would allow you to call it as:

my $data = foldl { . . . } $base, @data;

Just like map/grep do now. You'll have to modify some of the code to handle the array ref being passed instead of a list.

Also, change the foreach to not save to a lexical, but rather use the default of saving to local $_ instead. That allows the subroutine to use a localized $_, just like map/grep do now.

----
send money to your kernel via the boot loader.. This and more wisdom available from Markov Hardburn.