| Home » Howtos » Using perl » Display text message |
This page illustrates three ways to display text using perl. As usual, we provide complete working examples for you to copy and paste.
#!/usr/bin/perl
use strict;
use warnings;
print "Some text\n";
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
my $mw = MainWindow->new;
$mw->title("Hello World");
$mw->Label(-text => "Hello World")->pack();
$mw->Button(-text => "Done", -command => sub {exit})->pack;
MainLoop;
Use the CGI module, create a CGI object (in the variable $q in our case), and call CGI methods like header and start_html to output the html.
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
my $q = new CGI;
print $q->header,
$q->start_html('Your page title'),
'Some plain text',
$q->b('Some bold text'),
$q->end_html;
Or using the CGI module's functional programming style, you could do the same with this code:
#!/usr/bin/perl
use strict;
use warnings;
use CGI qw/:standard/;
print header,
start_html('Your page title'),
'Some plain text',
b('Some bold text'),
end_html;