The stellar initial mass function (IMF) is one of the cornerstones of modern astrophysics and its universality or potential variation has important consequences on the evolution of galaxies and their chemical enrichment, the dynamics of interstellar gas, and the evolution of individual stellar clusters. In this talk, I will discuss the evolution of the mass function of dense cores (CMF) in a star forming clump, and the transition from the CMF to the IMF. In particular, I will demonstrate how several physical processes such as the coalescence of cores, gas accretion by the cores and feedback by the newly formed OB stars shape the CMF and the corresponding IMF. I will also discuss how the metallicity of the gas in the star forming regions can regulate the star formation efficiency and the implication of this for the star formation laws in galaxies.