Interesting idea.
I see two problems with it. The first is that while do 'file.pl'; looks neat and tidy, by the time you add the required error checking around each one it is less so and you'll find yourself wanting to wrap the error checking into a subroutine, which sort of defeats the purpose.
The second is that the code will be reinterpreted and compiled each time you need to use it, which would dramatically slow your script down.
You could avoid this by including the contents of the files using require 'file.pl'; but then you'd need to wrap the contents of the file in a subroutine so that you could call it more than once, or you have the same problems of reinterpreting it each time. Once you've wrapped it in a sub, your almost back to where you started, though it would achieve your aims of seperating "implementation from logic", but unless the routines in the files are going to be re-used in multiple programs, I would find it easier to maintain them all in a single file. And if they where to be re-used in multiple files, better to make it a module and use it.
In reply to Re: Do file.pl (replacing subs?)
by BrowserUk
in thread Do file.pl (replacing subs?)
by BUU
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |