Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: using a subroutine

by beable (Friar)
on Aug 08, 2004 at 22:57 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-19 19:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found