PDA

View Full Version : compiling and running perl/tk


bsdnewbie999
08-09-2008, 03:32 AM
How do I compile and run a perl/tk program using terminal?:confused:

Carpetsmoker
08-09-2008, 03:51 AM
perl myscript.pl

It's as simple as that

ai-danno
08-09-2008, 03:11 PM
Are you interested in learning to program in perl and tk? Or are you interested in compiling and running programs/scripts that others have written?

If you are interested in the programming side, I would suggest the "Learning Perl" book by O'Reilly Publishing (http://oreilly.com/catalog/9780596101053/), affectionately known as the "The Llama". It's out of print but available online. And it's completely worth it.

ocicat
08-09-2008, 03:30 PM
It's out of print but available online.
The fifth edition of Learning Perl was published in June 2008:

http://oreilly.com/catalog/9780596520106/

If copies cannot be found in bookstores, it can be ordered online. As ai-danno, I agree that this is a very good introduction to Perl, but it does not cover Perl/Tk.

drl
08-10-2008, 11:22 AM
Hi.

Assuming you have entered the following with an editor of your choice:
#!/usr/bin/perl

# @(#) p1 Demonstrate perl/tk.
# Learning Perl/Tk, O'Reilly, Walsh, 1999, page 11.

use Tk;

my $mw = MainWindow->new;
$mw->title("Hello, world.");
$mw->Button( -text => "Done", -command => sub {exit} )->pack;
MainLoop;
You then may do:
chmod +x p1
./p1
and a small window will be created on your console, assuming all other prerequisites are handled: X is up, perl is at /usr/bin/perl, etc. This allows you to use this file just like a standard command. I prefer this method. I rarely code in perl/tk, but I have standardized comments for processing with command what -- that's what the @(#) comment is about -- you don't need that to run perl codes. The chmod need only be done once. After that, edit to your heart's content, and re-run with ./p1

See also the reference below ... cheers, drl

Title: Learning Perl/Tk
Author: Nancy Walsh
Edition: 1st
Date: 1999
Publisher: O'Reilly
ISBN: 1565923146
Pages: 376
Categories: programming, perl, tk
Comments: 3 stars (33 reviews, Amazon, 2008.08)
Comments: More recent: Mastering Perl/Tk, 2002