Ignore packages that are not currently installed when using "apt-get remove"

Is falling back to lower-level tool such as dpkg an option?

dpkg --remove foo bar libperl-dev
dpkg: warning: ignoring request to remove foo which isn't installed
dpkg: warning: ignoring request to remove bar which isn't installed
(Reading database ... 169132 files and directories currently installed.)
Removing libperl-dev ...

To remove packages config files use purge as below

dpkg --purge foo bar libperl-dev

I use apt-get remove --purge (aka apt-get purge) for the dependency following with a list of packages. To handle packages that don't exist I filter out packages that are not installed with the following script.

pkgToRemoveListFull="cups-dbg bogus-package"
pkgToRemoveList=""
for pkgToRemove in $(echo $pkgToRemoveListFull); do
  $(dpkg --status $pkgToRemove &> /dev/null)
  if [[ $? -eq 0 ]]; then
    pkgToRemoveList="$pkgToRemoveList $pkgToRemove"
  fi
done
apt-get --yes --purge remove $pkgToRemoveList

For Debian ≤ 9, it is possible to just use aptitude instead of apt-get:

sudo aptitude remove -y cups-dbg bogus-package

Aptitude prints warnings, but continues to remove your packages nevertheless:

Couldn't find any package whose name or description matched "bogus-package"
...
Removing cups-dbg ...
...

If you want to purge (delete package config files) rather than remove (keep config files), note that aptitude only purges the directly given packages, while the unused dependencies are only removed. However, you can purge all removed packages in a second step:

apt-get -y purge $(dpkg -l | grep ^rc | awk '{print $2}')