in reply to Re^2: Subroutines vs Modules
in thread Subroutines vs Modules

...a module can be easily transported between programs of somewhat similar context and can be thought of as "universal" code. Whereas, subroutines are moreso used by the creator himself and is made for that program alone and not really thought to be exported to other programs.

you are looking at the consequences of modules vs. subroutines, and your observations are correct, but only because there are technical reasons that make them so

Fundamentally speaking, a subroutine and the subroutines IN a module are identical (note that your "subroutine to module" comparison is not quite apples to apples)*, they differ by being subroutines that exist in different namespaces (aka., in perl, packages)

it's because you can segregate your subroutines by namespace in this way that makes it easy to move the code between programs (and programmers) - it also helps that modules typically exist in separate files too (of course).

*footnote: it's an easy mixup to make, because most modules present themselves as offering a single object, sometimes a single subroutine even

Replies are listed 'Best First'.
Re^4: Subroutines vs Modules
by Anonymous Monk on Jan 04, 2006 at 13:59 UTC
    (note that your "subroutine to module" comparison is not quite apples to apples)*
    subroutine is to module as apples are to labeled basket of apples