Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re^2: using a subroutine

by beable (Friar)
on Aug 08, 2004 at 22:57 UTC ( #381123=note: print w/replies, xml ) Need Help??

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.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://381123]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2023-03-26 02:17 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (63 votes). Check out past polls.