> Testing a simple script under modperl  using Registry and -X and Apache::DB,
> as explained by Stas Bekman
> 
> It runs OK about seven times then it fails.  Here is the error_log output:
> 
> resize:  can't open terminal /dev/tty
> [Fri Oct  8 07:47:39 1999] [error] Unable to get Terminal Size. The TIOCGWINSZ
> ioctl didn't work. The COLUMNS and LINES environment va
> riables didn't work. The resize program didn't work. at
> /users/webuser/lib/perl5/site_perl/5.005/sun4-solaris/Term/ReadKey.pm line 323
> .
>         diagnostics::death_trap('Unable to get Terminal Size. The TIOCGWINSZ
> ioctl didn\'t work. ...') called at /users/webuser/lib/pe
> rl5/site_perl/5.005/sun4-solaris/Term/ReadKey.pm line 323
>         Term::ReadKey::GetTerminalSize('GLOB(0x9c7e6c)') called at
> /users/webuser/lib/perl5/site_perl/5.005/Term/ReadLine/readline.pm
> line 242
>         readline::get_window_size called at
> /users/webuser/lib/perl5/site_perl/5.005/Term/ReadLine/readline.pm line 610
>         readline::init called at
> /users/webuser/lib/perl5/site_perl/5.005/Term/ReadLine/readline.pm line 92
>         require Term/ReadLine/readline.pm called at
> /users/webuser/lib/perl5/site_perl/5.005/Term/ReadLine/Perl.pm line 58
>         eval {...} called at
> /users/webuser/lib/perl5/site_perl/5.005/Term/ReadLine/Perl.pm line 58
>         Term::ReadLine::Perl::new('Term::ReadLine', 'perldb', 'GLOB(0x9ec63c)',
> 'GLOB(0x9c7e6c)') called at /users/webuser/lib/perl5/s
> ite_perl/5.005/sun4-solaris/Apache/perl5db.pl line 1462
>         DB::setterm called at
> /users/webuser/lib/perl5/site_perl/5.005/sun4-solaris/Apache/perl5db.pl line
> 476
>         DB::DB called at (eval 2949) line 1
>         Apache::ROOT::perl::tc_test::handler('Apache=SCALAR(0x9c7ea8)') called
> at /users/webuser/lib/perl5/site_perl/5.005/sun4-solari
> s/Apache/Registry.pm line 140
>         eval {...} called at
> /users/webuser/lib/perl5/site_perl/5.005/sun4-solaris/Apache/Registry.pm line
> 140
>         Apache::Registry::handler('Apache=SCALAR(0x9c7ea8)') called at
> /users/webuser/lib/perl5/site_perl/5.005/Term/ReadLine/readline
> .pm line 0
>         eval {...} called at
> /users/webuser/lib/perl5/site_perl/5.005/Term/ReadLine/readline.pm line 0
> 
> #########################################################################

Try running under interactive debug mode, like in
http://perl.apache.org/guide/debug.html#Apache_DB_Run_the_interactive

You made a mess of using Exporter and direct package variables access! See
below:

> Here are the two pieces of code, tc_test and Test_Package.pm
> 
> #!/usr/local/bin/perl   -w
> # tc_test
> use strict;
> use diagnostics;
> 
> use lib qw(./Modules);
> use Test_Package;

Here you exported the variables, now they are global to your script! 
That's because you have used @EXPORT instead of @EXPORT_OK export list.
But you cannot use them before you declare them with 'use vars' because of
'use strict'; Why do you the so called thrick to access them thru their
original package?  You want to use 'use Test_Package ();' to avoid
automatic exporting. 

> 
> print "<BR>TCLIST=$Test_Package::TCLIST\n";
> print "<BR>Colors = \n";
> foreach my $color (@Test_Package::COLORS){
>     print "<BR>$color\n";
> }
> 
> and in my Modules directory
> 
> package Test_Package;
> #    use strict;
>     use vars qw (@EXPORT $VERSION @ISA );
>     use Exporter;
>     $VERSION = 1.00;
>     @ISA = qw(Exporter);
>     @EXPORT = qw ($TCLIST @COLORS);

Tip: use @EXPORT_OK and not @EXPORT, so user will have fine control of
over what symbols are being imported into a script's namespace.

> #########################################################################
>     $TCLIST = "./tc_list_storms";
>     @COLORS = qw (red orange yellow green blue violet);
> ########################################################################
> 1;
> ~~

Anywhere the code below works:

[/home/httpd/perl]> more Test_Package.pm 
package Test_Package;
use strict;
$Test_Package::VERSION = 1.00;
$Test_Package::TCLIST = "./tc_list_storms";
@Test_Package::COLORS = qw (red orange yellow green blue violet);
1;

[/home/httpd/perl]>more test.pl
use strict;
use lib qw(.);
use Test_Package ();

print "Content-type: text/plain\n\n";
print "TCLIST=$Test_Package::TCLIST\n";
print "Colors: ", join " ", @Test_Package::COLORS;

The Exporter is left to you as an exercise :)

> It also fails under PerlRun.   However under  PerlRun it prints the variables
> a variable number of times, then suddenly stops and will not print again
> till the server is restarted.
> 
> Appreciate any assistance as to why this is failing.  As you can see
> I tried the Package::some_variable trick suggested by Stas but it doesn't
> seem to solve the problem.
> 
> Thank you very much,
> 
> John Kent
> Naval Research Laboratory
> Monterey California
> ~~
> 
> 



_______________________________________________________________________
Stas Bekman  mailto:[EMAIL PROTECTED]    www.singlesheaven.com/stas  
Perl,CGI,Apache,Linux,Web,Java,PC at  www.singlesheaven.com/stas/TULARC
www.apache.org  & www.perl.com  == www.modperl.com  ||  perl.apache.org
single o-> + single o-+ = singlesheaven    http://www.singlesheaven.com

Reply via email to