http://www.perlmonks.org?node_id=994033

supriyoch_2008 has asked for the wisdom of the Perl Monks concerning the following question:

Hi PerlMonks,

I am a beginner in perl programming. I have tried to create the first GUI using the hello.pl program. But I am getting an error in cmd like "Can't locate loadable object for module Tk::Event in @INC (@INC contains: C:/Per l/site/lib C:/Perl/lib .) at C:/Perl/lib/Tk.pm line 13". I have given the script of hello.pl and the Event.pm below. I am looking for help from perlmonks to sort out this problem in creating the GUI using hello.pl.

The code of hello.pl is given below:

#!/usr/local/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;

I have used the following Event.pm within Tk directory of perl lib installed in C drive of my laptop:

package Tk::Event; use vars qw($VERSION $XS_VERSION @EXPORT_OK); END { CleanupGlue() } $VERSION = sprintf '4.%03d', q$Revision: #15 $ =~ /\D(\d+)\s*$/; $XS_VERSION = '804.027'; use base qw(Exporter); use XSLoader; @EXPORT_OK = qw($XS_VERSION DONT_WAIT WINDOW_EVENTS FILE_EVENTS TIMER_EVENTS IDLE_EVENTS ALL_EVENTS); XSLoader::load 'Tk::Event',$XS_VERSION; require Tk::Event::IO; 1; __END__

I am getting the following error message again and again in cmd window.

Microsoft Windows [Version 6.1.7600] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Users\x>cd desktop C:\Users\x\Desktop>hello.pl Can't locate loadable object for module Tk::Event in @INC (@INC contai +ns: C:/Per l/site/lib C:/Perl/lib .) at C:/Perl/lib/Tk.pm line 13 Compilation failed in require at C:/Perl/lib/Tk.pm line 13. BEGIN failed--compilation aborted at C:/Perl/lib/Tk.pm line 13. Compilation failed in require at C:\Users\x\Desktop\hello.pl line 2. BEGIN failed--compilation aborted at C:\Users\x\Desktop\hello.pl line +2. C:\Users\x\Desktop>

Replies are listed 'Best First'.
Re: Where am I going wrong in the code for creating the first GUI using hello.pl?
by zentara (Archbishop) on Sep 17, 2012 at 13:48 UTC
    Reinstall Tk properly., It sounds like you have a mismatch in binary version, something like you installed a ppm module compiled for one Perl version and Windows level, which dosn't match yours. Possibly did you upgrade your Perl version lately, and didn't rebuild Tk, or install the correct compatible Tk ppm.

    What version of Windows do you have, and how did you install Tk?


    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
Re: Where am I going wrong in the code for creating the first GUI using hello.pl?
by daxim (Curate) on Sep 17, 2012 at 13:42 UTC
    Which Perl distribution do you use, and what's the version number? I suspect Tk was not properly installed, how did you install it?