Another instance of good practice / paranoid checking: since this is from user input, we can't trust it. Therefore we need to coerce it to int, so we're sure it's a number (or 0)

suggestion:

   my $filterid = $GET{filterid} + 0;