Das lässt sich leicht durch eine medientypspezifische Stilangabe lösen, zum Beispiel so:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use 5.012;
use warnings;
use utf8;
use CGI;
my $javascript = <<'END';
function printpage() {
window.print()
}
END
my $css = <<'END';
@media print {
.hideme { display: none; }
}
END
my $cgi = CGI->new();
print $cgi->header( -charset => 'UTF-8' );
print $cgi->start_html(
-style => {
-type => 'text/css',
-code => $css
},
-script => {
-type => 'text/javascript',
-code => $javascript
});
print $cgi->p( 'Hello World' );
print $cgi->start_form();
print $cgi->button( -name => 'button_1', -value => 'Print', -onClick => 'printpage()', -class => 'hideme' );
print $cgi->end_form();
print $cgi->end_html();
When C++ is your hammer, every problem looks like your thumb.