stop the_permalink printing and save as variable?

Use get_permalink() instead. (Codex ref.)

Per the WordPress function-naming convention, most functions have two forms: the_*() and get_*(); the the_*() functions will print the output, and the get_*() functions will return the output.