Recently I’ve found a quite intersting an article “How How a script becomes a module” written by brian_d_foy.
The article is nice and useful but it can be stated in two lines: if you need a simple thing like dragonchild example:
#!/bin/sh
for file in $*
do
echo “$file”
Perl -pi -e ‘s! (?= |$)! \N!g;s#\(?!N)#\\#g’ $file
done
Sure, it’s reasonable just copy that code into another script and the end of story. But if you have a complicated common functionality it will be better to keep it into the module.