The following is not the proper way to modularize your code, but because you are just 'one yard before the finish line' you could use a script
or Makefile to concatenate multiple files to a single program. That is easier and less error prone
then the temporary "manually cut and paste" solution, that you are considering.
Assuming you have the following files:
-rw-r--r-- 1 hadri hadri 51 Feb 12 04:24 main_barack
-rw-r--r-- 1 hadri hadri 63 Feb 12 04:15 my-serial-library.src
-rw-r--r-- 1 hadri hadri 68 Feb 12 04:27 postlude_general.src
Your general libary routines are in my-serial-library.src and postlude_general.src.
The 'main' program is the only customized part and is named after your client or location: main_barack.
With a simple Makefile you can generate your program serial_com_barak.pl:
$ make
cat my-serial-library.src main_barack postlude_general.src > serial_co
+mm_barack.pl
For another customer you create a new customized main and run 'make' again:
$ echo "This is for Bernie" > main_bernie
$ make CLIENT=bernie
cat my-serial-library.src main_bernie postlude_general.src > serial_co
+mm_bernie.pl
The Makefile:
# -- sample Makefile
CLIENT = barack
NAME = serial_comm
PROG_NAME = ${NAME}_${CLIENT}.pl
PRELUDE = my-serial-library.src
MAIN = main_${CLIENT}
POSTLUDE = postlude_general.src
TAR_NAME = serial-comm_${CLIENT}.tgz
TAR_FILES = Makefile
TAR_FILES += ${PRELUDE} ${MAIN} ${POSTLUDE}
${PROG_NAME}: ${PRELUDE} ${MAIN} ${POSTLUDE}
cat ${PRELUDE} ${MAIN} ${POSTLUDE} > ${PROG_NAME}
clean:
rm -rf ${PROG_NAME}
archive:
tar cvzf ${TAR_NAME} ${TAR_FILES}
# --- end of Makefile
Note: Make sure that you have a tab character (\x09, CNTRL-I or ^I) before the cat and other commands in the Makefile.Verify with 'cat -t Makefile':
${PROG_NAME}: ${PRELUDE} ${MAIN} ${POSTLUDE}
^Icat ${PRELUDE} ${MAIN} ${POSTLUDE} > ${PROG_NAME}
|