COBOL copy books

identification division.
program-id. big_program.
environment division.
data division.
working-storage section.
copy 'person_dd.cob' replacing ==:block:== by alice.
copy 'person_dd.cob' replacing ==:block:== by bob.
procedure division.100-start.
move 32 to age in alice
move 'alice' to name in alice
move 27 to age in bob
move 'bob' to name in bob
perform display-alice
perform display-bob
goback.copy 'person_pd.cob' replacing ==:block:== by alice.
copy 'person_pd.cob' replacing ==:block:== by bob.
01 :block:.
05 age PIC 9(3).
05 name PIC X(10).
display-:block:.
display 'name ' name in :block:
display 'age ' age in :block:
.
$ cobc -x big_program.cob && ./big_program
name alice
age 032
name bob
age 027
$ cobc -E big_program.cob -o big_program.p && cat big_program.p
#line 1 "big_program.cob"
identification division.
program-id. big_program.
environment division.
data division.
working-storage section.

#line 1 "person_dd.cob"
01 alice.
05 age PIC 9(3).
05 name PIC X(10).
#line 6 "big_program.cob"
#line 1 "person_dd.cob"
01 bob.
05 age PIC 9(3).
05 name PIC X(10).
#line 7 "big_program.cob"
procedure division.
100-start.
move 32 to age in alice
move 'alice' to name in alice
move 27 to age in bob
move 'bob' to name in bob
perform display-alice
perform display-bob
goback.
#line 1 "person_pd.cob"
display-alice.
display 'name ' name in alice
display 'age ' age in alice
.
#line 18 "big_program.cob"
#line 1 "person_pd.cob"
display-bob.
display 'name ' name in bob
display 'age ' age in bob
.
#line 19 "big_program.cob"

Notes

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store