Thanks for the nudge in the right direction. The crux of the problem is that the imported exit() does not have a prototype and overrides the built-in exit() which has a prototype of ($) [takes exactly one scalar argument].
I'm really starting to wish for a
pragma to disallow the "indirect object" syntax such as:use strict "object"
which is already heavilly discouraged by many.my $obj= new Neural::Net( "adaptive" );
I knew that < exit &main( @ARGV ) > would fix the problem because "&main" is no longer a bareword. Finding that declaring "sub main" also fixed it got me wondering.
Since normally the parens in "main( @ARGV )" are clearly enough to tell Perl that "main" is a subroutine (you may need an & to tell Perl that you want your subroutine and not some built-in with the same name), the fact that "exit main( @ARGV )" always worked for me convinced me that I wasn't being ambiguous.
But it appears that exit() being a function isn't enough to cause Perl to interpret "exit main( @ARGV )" as "exit( main(@ARGV) )". But having "sub exit($);" is enough.
This confuses me because I thought one of the big problems with the indirect object syntax was:
because that last line would call Widget::new() instead of WingNut::new(). But it "works" for me. Oh well. - tye (but my friends call me "Tye")package Widget; use WingNut; sub new { # Doesn't matter } sub Method { my $self= shift( @_ ); $self->{SubObj}= new WingNut(@_); # oops!! }
In reply to (tye)Re: Tk: exit main(@ARGV); fails
by tye
in thread Tk: exit main(@ARGV); fails
by tye
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |