Order of subroutines

From: Aris Xanthos (Aris.Xanthos_at_ling.unil.ch)
Date: 09/28/04


Date: 28 Sep 2004 03:58:58 -0700

Hi,

I have a problem with the order of subroutines
and I couldn't find help about that in books or
online.

Could someone tell me why this code works fine:

------------------
 #!/usr/bin/perl

 Function1();

 sub Function1() {
   Function2( 'arg' );
 }

 sub Function2() {
   my ( $arg ) = @_;
 }

------------------

and not this one:

------------------
 #!/usr/bin/perl

 Function1();

 sub Function2() {
   my ( $arg ) = @_;
 }

 sub Function1() {
   Function2( 'arg' );
 }

------------------

which yields the following error message:

Too many arguments for main::Function2 at
D:\Developpement\Perl\test.pl line 10, near "'arg' )"
Execution of D:\Developpement\Perl\test.pl
aborted due to compilation errors.

I have this problem in the framework of a rather
long (tk) script (about 2'000 lines so far), and the
calls to various subroutines are getting too intricate
for me to find an order that works (besides, it is not
a satisfying solution).

I hope this does not duplicate a previous post.

Aris Xanthos



Relevant Pages

  • Re: Sub routine location
    ... > does the calling to subroutines etc. ... of an error message isn't jumping out at me as immediately familiar. ... and you get a warning telling you about it. ... prototypes in the first place. ...
    (comp.lang.perl.misc)
  • Re: reference a vb.net windows form control from a module sub
    ... > application with a few subroutines in a separate module. ... > label or text box on the form. ... > a "Reference to a non-shared member requires an object ... error message. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Order of subroutines
    ... > which yields the following error message: ... > aborted due to compilation errors. ... > calls to various subroutines are getting too intricate ... You probably don't realise that you are defining a prototype for ...
    (comp.lang.perl.misc)
  • Re: Order of subroutines
    ... Aris Xanthos wrote: ... > I have a problem with the order of subroutines ... > and I couldn't find help about that in books or ... > online. ...
    (comp.lang.perl.misc)