http://qs321.pair.com?node_id=381123


in reply to Re: using a subroutine
in thread using a subroutine

Why not just place your subs whereever you like, call them from whereever you like without & and with (), and not use forward declarations either? What am I missing? Perl isn't C. This seems to work for me:
#!/usr/bin/perl use strict; use warnings; aaa("Hello world"); sub aaa { my $arg = shift; my $quit = shift; print("I am aaa, arg = $arg\n"); exit 0 if ($quit); bbb("hello bbb"); } sub bbb { my $arg = shift; print("I am bbb, arg = $arg\n"); ccc("hello ccc"); } sub ccc { my $arg = shift; print("I am ccc, arg = $arg\n"); aaa("hello aaa", 42); } __END__

Replies are listed 'Best First'.
Re^3: using a subroutine
by ysth (Canon) on Aug 08, 2004 at 23:15 UTC
    I agree, but if you are in the habit of leaving off (), it may be easiest to predeclare.