in reply to Opening a new window and writting to it

You can use a state machine. It can be as simple as having a "printable=1" key:

if ( $printable ) { # print it printable print "<h1>RESULTS</h1>"; } else { print "<p>Welcome to the calling page</p>\n"; print "<a href=xxxx?printable=1 target=\"_blank\">Click for Printa +ble version</a>"; }

untested, may contain several syntax errors.