in reply to "Less" perl output

What you are describing is the "alternate screen" feature that some terminal emulators have. The linux virtual console, for instance, doesn't have this feature.

not leaving a trace in your terminal.

Actually this is not 100% true. In xterm you can find "Show alternate screen" in the menu that opens when you hold down Ctrl-MiddleButton. Even after less has been quit, xterm still shows its display (of your secret files) in the alternate screen.

Update: Regarding your question how you can do this: I think that ncurses (which "less" uses) does this by default when you initiate the screen, so you should be able to do this with the Curses module (as atcroft suggests).