It needs to be enclosed with:
sub {
... the code goes here ...
}
Edit: By the way, you need to pass the category id into the global and then replace $CategoryID with $_[0]
sub {
... the code goes here ...
}
Edit: By the way, you need to pass the category id into the global and then replace $CategoryID with $_[0]