When you have your inbox selected on your old mac, click “Mailbox” in the menubar, then click “Archive Mailbox…”. Save the file it creates on to a memory stick or a CD, then copy it over to your new computer.
Once you’re at your new computer, open mail and click “File” in the menubar, then “Import Mailboxes…”. From the options presented, click “Mail for Mac OSX”. It will then ask you to locate the file you created earlier. Once you have chosen it, all your emails will be imported.
Once you’ve copied over your files, you’ll still have to set up Mail with your Yahoo account to get any new emails you receive, if you haven’t already done so. If you haven’t done this, just go to “File” and then click “Add Account…”, and follow the wizard. It’s really easy to follow so you shouldn’t have any problems. If you do, have a look at Yahoo’s help page on POP.