We study the evolutionary Prisoners Dilemma on two social networks obtained from actual relational data. We find very different cooperation levels on each of them that can not be easily understood in terms of global statistical properties of both networks. We claim that the result can be understood at the mesoscopic scale, by studying the community structure of the networks. We explain the dependence of the cooperation level on the temptation parameter in terms of the internal structure of the communities and their interconnections. We then test our results on community-structured, specifically designed artificial networks, finding perfect agreement with the observations in the real networks. Our results support the conclusion that studies of evolutionary games on model networks and their interpretation in terms of global properties may not be sufficient to study specific, real social systems. In addition, the community perspective may be helpful to interpret the origin and behavior of existing networks as well as to design structures that show resilient cooperative behavior.