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

use strict "object"
pragma to disallow the "indirect object" syntax such as:
my $obj= new Neural::Net( "adaptive" );
which is already heavilly discouraged by many.

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:

package Widget; use WingNut; sub new { # Doesn't matter } sub Method { my $self= shift( @_ ); $self->{SubObj}= new WingNut(@_); # oops!! }
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")

In reply to (tye)Re: Tk: exit main(@ARGV); fails by tye
in thread Tk: exit main(@ARGV); fails by tye

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.