Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run Perl TK under Windows 1

Status
Not open for further replies.

bkelly13

Programmer
Joined
Aug 31, 2006
Messages
98
Location
US
I have just received an assignment to extract data from multiple logs and merge the data together to chart for analysis. I am brand new to Perl and just managed to install version 5.8 from ActiveState under Windows 2000. There is a huge amount of documentation but nothing that says: to start using perl TK do this: <something>

the existing scripts start with:
use strict;
use utils::stat qw(toSec interpolate);

None have the shebang mentioned in the book: #!

In short, how do I get a hello world window going using Perl Tk?

Thanks for your time,
Bkelly
 
Code:
use strict;
use utils::stat qw(toSec interpolate);
use Tk;

my $mw = MainWindow->new (
   -title => 'My Tk Window',
);

$mw->Label (
   -text => 'Hello World!',
)->pack;

MainLoop;
 
Hello Kirsle,
Thanks for your reply. There is someing about my configuration that does not match the standard. I pasted your code into a file and ran it from a DOS window with:
perl hello.pl
the response is
Can't locate utils/stat.pm in @INC <@inc CONTAINS C:\Perl\lib C:\Perl/site/lib.> at hello.pl line 2. BEGIN failed--compilation aborted at hello.pl line 2.

I searched the Perl directory for stat.pm and found it in C:\Perl\lib\File. When I tried changing line 2 of the file to direct it to this directory, I coult not get it working right.

I do not have a Perl\utils directory.
Last night I ran a program named something like Pked, an editer written in Perl TK. (It took such a long time to find it, I am not going to do that again at this moment) The editor started and ran. this tells me that Perl TK is functional. But maybe I miss-interpert.

There is a directory named C:\Perl\site\lib\Tk\pTk

Your advise?

Thanks again for your time,
Bkelly
 
Tk is the GUI Toolkit. Straight Perl will work for what you are doing. I use Crimson Editor for my scripting. Once the script is saved, and the '.pl' extension is associated with Active Perl, just type in the name of the program, with extension, at the command prompt. You can also just double-click on the script in Windows Explorer (or on the desktop), if you don't need to see the output.
Shebang is used under *nux; something about the Perl executable filepath, I think. It's generally ignored under Windows.
Google the words 'Perl' and 'tutorial' together. Perl is a relatively easy language.

 

...A 'hello world' program can be as simple as:

print "Hello World!\n";
 
Util::Stat and File::Stat are two completely different modules.

You can get almost any module that exists by searching it at
When I posted that hello world script I was going starting with the example you already posted, but here's a simpler one that only uses Perl Tk.

Code:
use Tk;

my $mw = MainWindow->new (
   -title => 'My Tk Window',
);

$mw->Label (
   -text => 'Hello World!',
)->pack;

MainLoop;
 
Hello All,
This is still part of a getting started kind of a thread so I will continue in the same thread.

The hello world is now working, Perl is running now under Windows 2000 on my computer (Dell Laptop)

The O'Reilly book "Learning Perl," Chapter 1, has the following example code:

Code:
use utils::stat;
@lines = `perldoc -u -f atan2`;
foreach (@lines)
   {
   s/\w<([^>]+)>/\U$1/g;
   print;
   }

The book indicates that the first line within the braces will change the text when it finds angle brackets. It indicated, but does not say outright, there will be a difference between running the program and executing the perldoc command from the command line. It does not say what differences I should expect. I did both (ran the perl program and enter the docs command) and found no difference in the two outputs. That indicates I have something wrong.

Please tell me my error.

Thanks for your time,
Bkelly
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top