jmaas has asked for the wisdom of the Perl Monks concerning the following question:
After gaining much perl wisdom by just reading, now i have to ask a question myself.
I have a small skript which is executing subs in wrong order. Although i have found out, that i was missing a semicolon, i do not understand, WHY the execution order is altered without this semicolon.
And hence my question is: Why?
The code:#!/usr/bin/perl use strict; use warnings; sub sub_A { print "sub_A\n"; } sub sub_B { print "sub_B\n"; } sub_A sub_B;
produces this output:
sub_B sub_A
After I add the missing semicolon after sub_A the output changes to the expected
sub_A sub_B
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: sub execution order aka missing semicolon after sub call
by choroba (Cardinal) on Apr 06, 2016 at 15:30 UTC | |
by jmaas (Initiate) on Apr 06, 2016 at 15:41 UTC | |
by johngg (Canon) on Apr 07, 2016 at 10:41 UTC | |
|
Re: sub execution order aka missing semicolon after sub call
by haukex (Archbishop) on Apr 06, 2016 at 15:30 UTC | |
|
Re: sub execution order aka missing semicolon after sub call
by davido (Cardinal) on Apr 06, 2016 at 15:30 UTC |