A procedure for the real-time analysis of laser modes using a phase-only spatial light modulator is outlined. The procedure involves encoding into digital holograms by complex amplitude modulation a set of orthonormal basis functions into which the initial field is decomposed. This approach allows any function to be encoded and refreshed in real time (60 Hz). We implement a decomposition of guided modes propagating in optical fibers and show that we can successfully reconstruct the observed field with very high fidelity.