subroutines may be located anywhere in the main program

D

Dan Jacobson

Perlsub says subroutines may be located anywhere in the main program;
and indeed,
$ perl -e 'if(0){sub x{print "wow"}};x;'
wow

Anything non ideal here?
 
T

Tassilo v. Parseval

Also sprach Dan Jacobson:
Perlsub says subroutines may be located anywhere in the main program;
and indeed,
$ perl -e 'if(0){sub x{print "wow"}};x;'
wow

Anything non ideal here?

Readability perhaps. At least I'd be confused to see a subroutine
declared in an if-branch.

Other than that, there is not much wrong with it as long as you don't
expect to impose a certain scope or visibility on your subroutines.
They'll always be globally accessible (within the same package) and Perl
doesn't know about inner functions or so.

Tassilo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,257
Messages
2,571,031
Members
48,768
Latest member
first4landlord

Latest Threads

Top