View Single Post
  #5   (View Single Post)  
Old 10th August 2008
drl's Avatar
drl drl is offline
Port Guard
 
Join Date: May 2008
Posts: 19
Default

Hi.

Assuming you have entered the following with an editor of your choice:
Code:
#!/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:
Code:
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

Quote:
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

Last edited by drl; 10th August 2008 at 10:25 AM.
Reply With Quote