Perl in Debian is split into several parts. One of these parts, the
perl-base package, is part of the set of "essential" packages. Debian defines these essential packages as "will always be installed on a debian system". Packages can assume they will be available, even if they do not have any form of dependency declared on them. If you remove one of them, then things are likely to go horribly wrong. For that reason, if you try to do so,
dpkg will complain very loudly and ask you to confirm that you want to break your system by literally entering the phrase
Yes, do as I say! , with punctuation and everything. Never do this; you will get the system in a state that it is highly unlikely to recover from by itself.
If you did, then your system is now broken. Do not despair, however; it is still possible to fix it.
- First, run
dpkg -l perl-base to confirm that you are indeed missing the
perl-base package. If the output of that command starts with
ii on the line that contains
perl-base, then this is not the problem and you have a different problem. In that case, post the exact error messages you get when trying to run some apt command. Otherwise debugging becomes a crystal ball problem.
- download the
perl-base package for whichever version of debian you are running.
- Next, run
ar x perl-base*deb. This will create three files in the current working directory:
control.tar.gz. Note: data.tar.gz could also be data.tar.xz. If you don't have
ar installed on your system, you can run this step on a different system, and copy the resulting files to the broken machine (any UNIX-like machine will work, doesn't have to be a debian box).
data tarball contains the files this package wants to put on the filesystem. Unpack it in the right location with the following command:
tar xvaf data.tar.* -C /. The
-C / bit is the important part here; it tells
tar to unpack relative to the root directory of the filesystem.
- Once you're here, the missing files are back on your system, and
dpkg as well as
apt will work again. However, you're not done yet; at this point, the files are there, but because of the way you've "installed"
dpkg will think it's not there and may start doing weird things. For that reason, it's necessary to install it "again", by running
dpkg -i perl-base*deb.
Everything should be fixed now. Next time, if
dpkg tells you to enter that phrase, do the smart thing and say 'no' ;-)