The AnyData.pm that you installed first will, if installed correctly, be in the perl/site/lib folder. When DBD-AnyData is correctly installed, the AnyData.pm that ships with it will be placed in the perl/site/lib/DBD folder - and will thus not clobber the AnyData.pm that was installed earlier.
You could even place DBD/AnyData.pm in perl/site/lib by hand, if you liked, but it's better to get on top of the correct ways to install modules as many modules are not so easy to install "by hand".