in reply to Re^2: make_path for creating directory tree
in thread make_path for creating directory tree

I need to understand how stuff works otherwise I'll soon be asking the same things again and annoy you all.

AnonyMonk has given a pretty good explanation above, but you need to understand where to look stuff up. That way, you'll be able to answer your own questions when the time comes that everyone else is too busy or too annoyed to answer them for you.

... I thought Perl reads the script line by line from top to bottom. Now in this example we first use make_path and then set the subroutine. Shouldn't the subroutine be on top of everything else?

In Perl, a subroutine can, in most cases, be defined anywhere in the program and at any time (compile- or run-time) just as long as it is defined when it is actually called at runtime (see perlintro and perlsub). The only examples I can think of that require prior definition or declaration of a function involve prototypes — but don't involve yourself with prototypes unless you have to; see Far More than Everything You've Ever Wanted to Know about Prototypes in Perl -- by Tom Christiansen.


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^4: make_path for creating directory tree
by Anonymous Monk on Dec 23, 2015 at 19:39 UTC
    The only examples I can think of that require prior definition or declaration of a function involve prototypes
    well, there're also function calls without parens :)
Re^4: make_path for creating directory tree
by fasoli (Beadle) on Dec 24, 2015 at 11:16 UTC

    Yep, of course I didn't want a free Perl lesson and I had already started looking stuff up :) Although some times (like now) you need a bit of explaining about what things are, because for example I spent a good bit last night googling "return map perl" and of course no tutorials came up.

    Thanks for clarifying about the subroutine! :)

    Happy holidays!