We study the evolutionary Prisoner's 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 propose to look instead at the mesoscopic scale, specifically to the community structure of the networks, and show that the reason for this different cooperation behavior can be traced back to their intermediate-scale features. We explain the dependence of the cooperation level on the temptation parameter in terms of the internal structure of the communities and their interconnections. Our results support the conclusion that studies of 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.