Ok, found the problem with the help of a colleague (and by reading the
manual again, although I thought I had read everything about the
problem...). In case anyone has the same problem, the solution goes
like this:
use Tie::IxHash;
my %myhash;
my $t = tie(%myhash, "Tie::IxHash");
%myhash = ("split" => "$dbname.$collection", "middle" => { $shard_key
=> "$id" });
$db->run_command(\%myhash);
So there were problems with braces and with the order of the commands
which can only be guaranteed by using Tie::IxHash (as mentioned in the
Perl MongoDB Tutorial).
All the best,
Peter