The following code:
produces:#!/usr/bin/perl -w use strict; use Tk; # use Tk qw( exit ); # Also produces same error. exit main( @ARGV ); sub main { # This part doesn't matter }
It appears that somehow Tk is overriding the exit() built-in in a way that doesn't define exit() as a function so that Perl interprets exit main( @ARGV ) as an "indirect object" thingy of the form "bareword bareword( args )", that is, "method package( args )", and calls "main"->exit( @ARGV ), that is, main::exit( "main", @ARGV ).Argument "main" isn't numeric in subroutine entry at tk.pl line 6.
Note that you can fix the problem by changing the one line to:
(or by commenting out the use Tk line).exit( main( @ARGV ) );
All I've found in Tk's Perl source code that appears relevant is:
There is no exit() function defined anywhere that I can find. Tk uses AutoLoading but it doesn't appear that exit() is autoloaded. So exit() must be an XS subroutine?use base qw(Exporter DynaLoader); @EXPORT = qw(Exists Ev exit MainLoop DoOneEvent tkinit);
Any more clues as to what is going on here? Is there something that Tk could do differently to prevent this (minor) problem [other than rename Tk::exit() and provide a new Tk::exit() that is a Perl wrapper for the renamed XS function]? Or is there a change to the XS subsystem that would "fix" this?
- tye (but my friends call me "Tye")In reply to Tk: exit main(@ARGV); fails by tye
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |