By helping others mostly. That may be by answering well questions posed by others (see Seekers of Perl Wisdom), or by expounding (see Meditations) in an entertaining and/or educational fashion on some aspect of Perl and the use of Perl.
One way to lose experience is to post spam in Meditations or any other section of PM.
You might ask yourself why you want to gain XP in the first place. Is there some specific PM-related power you're wanting? Do you want to be able to vote, have a monkpic, approve nodes, or consider nodes? Do you want to game a high rank on PM and use that rank to help land a job? That's unlikely to work. Do you think having a higher XP score will make you cool? Do you want XP for the sake of XP as a game?
I think you'll find it's easier to get XP as they come when you worry about the Perl and Perlmonks communities. If you post nodes that show you care and are willing to put some time into helping other members (and anonymous monks), XP takes care of itself. If you don't care about Perl and the Perl community, this is probably the wrong site for you anyway.