PDA

Click to See Complete Forum and Search --> : [RESOLVED] Where to start?


Claude2005
Aug 3rd, 2010, 01:46 AM
Hello there,

To start, feel free to move this if you find this thread inappropriate to this section of the forum. Next, my concern, I just started playing around with Perl just a few days ago and I'm wondering anyone could point me to the right direction.

I'm trying to develop a simple application, like "Hello World!", in a Windows environment. I already installed ActivePerl (http://www.activestate.com/activeperl) and kept the default settings. I also downloaded Tk 804.028 (http://search.cpan.org/~srezic/Tk-804.028/) and unzipped it to C:\Tk-804.208\. Everytime I ran my script, this error occurs

Can’t locate Tk.pm in @INC <@INC contains: C:/Perl/site/lib C:/Perl/lib .> at tk1.pl line 2

Here's my script

#! c:\perl\bin\perl
use Tk;
# Main Window
my $mw = new MainWindow;
my $label = $mw -> Label(-text=>"Hello World") -> pack();
my $button = $mw -> Button(-text => "Quit",
-command => sub { exit })
-> pack();
MainLoop;

If I change c:\perl\bin\perl with c:\Tk-804.208\Tk this error occur

Can't exec c:\Tk-804.029\Tk at tk1.pl line 1.

If I can get past this problem, I can already start developing applications for a UNIX/LINUX environment.

As a side question, can I use Visual Basic instead of Perl/Tk?

Thanks in advance :D

tr333
Aug 5th, 2010, 11:38 PM
I've never used ActivePerl so I can't help with that side, but StrawberryPerl (http://strawberryperl.com/) is more of a unix-style perl port for windows than ActivePerl and I've been using it for a long time without problems. With StrawberryPerl you could try using the CPAN shell to install Tk.

If you want to develop for a Unix/Linux environment, then I would definitely recommend StrawberryPerl over ActiveState.



C:\> cpanp -i Tk

tr333
Aug 5th, 2010, 11:52 PM
I would also recommend using the following pragmas to improve coding:

use warnings;
use strict;

Put them above the "use Tk;" line. You also don't need the space between the #! and the c:\ on the first line. It's not actually used on Win32 except for parsing arguments to the perl.exe like:
#!C:\strawberry\perl\bin\perl.exe -wT
It's used on unix systems to tell the OS which program to run the script with, since the OS doesn't use file extensions.

tr333
Aug 5th, 2010, 11:57 PM
I just managed to successfully install Tk on StrawberryPerl and run the following Tk program:

Install Tk:
C:\> cpanp -i Tk

perl program:
#!c:\strawberry\perl\bin\perl.exe

use warnings;
use strict;

use Tk;
# Main Window
my $mw = new MainWindow;
my $label = $mw -> Label(-text=>"Hello World") -> pack();
my $button = $mw -> Button(-text => "Quit",
-command => sub { exit })
-> pack();
MainLoop;

As another thing, you might want to configure your perl/tk scripts on windows to be run by wperl.exe instead of perl.exe so you don't get the cmd.exe window appearing each time. I'm not sure how to exactly do that but you could use a different file extension and tell windows to run that with wperl.exe.

Claude2005
Aug 6th, 2010, 03:58 AM
Thanks man.