I have created a layer with a variable substitution to request wether or not a bird species has been observed in a town. It works ok. But if I make a WMS GetCapabilities I only see one layer as expected. I have more than hundred species so if I want to have the GetCapabilities request to show one layer for each species do I need to generate a huge mapfile? Does anyone can suggest some tips/trick to make this work easier?
Variable substitution works with WMS, it is however not compliant with the WMS spec itself. Given you want to show all species in your capabilities document, i.e. be somewhat compliant with the WMS spec, you either have the option of, as you said, creating your hundred layers, or using the "dimension" support that was added in version 6.2, c.f. http://mapserver.org/fr/ogc/wms_dimension.html .
Supposing you go for option 2, you would still however have to manually list in the mapfile the whole list of available species. I also suspect that support for generic WMS dimensions (i.e. not TIME or ELEVATION) on the client side is very limited if at all existant.