in reply to Re^3: how to move multiple files
in thread how to move multiple files
However, I imagine you're asking that because...
I'm curious why you used a sub given that it's a script, not a module, and it only gets called once.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: how to move multiple files
by eyepopslikeamosquito (Archbishop) on Sep 09, 2023 at 00:36 UTC | |
I'm curious why you used a sub given that it's a script, not a module, and it only gets called once Bod, further to kcott's excellent reply (especially "a subroutine abstracts functionality and promotes reuseability; it has nothing to do with script vs. module" ++) a few more thoughts on the tricky topic of how best to test end user scripts. My preferred approach is to abstract the work the script does into CPAN-like modules and unit test each module using Test::More and the prove command. Accordingly, I strive to keep my script mainlines as short as is practicable. There are many examples of this approach on the CPAN; the perltidy command, for example, is effectively a one-liner:
Though I'm not a fan, an alternative approach, concocted by brian_d_foy (who has made 93 fewer posts than you ;-), is modulinos (how a script becomes a module). | [reply] [d/l] [select] |
Re^5: how to move multiple files
by kcott (Archbishop) on Sep 08, 2023 at 23:25 UTC | |
G'day Bod, "I'm curious why you used a sub given that it's a script, not a module, and it only gets called once." My example code only called it once for demonstration purposes. A subroutine abstracts functionality and promotes reuseability; it has nothing to do with script vs. module. The OP's production code may want to use it multiple times. Here's move_to_phone_4.pl which, after adding some files for my explanation to you, shows: [Those last three points are mainly for the OP's benefit.]
The output's getting lengthy but here's a sample run:
— Ken | [reply] [d/l] [select] |