Then, the Skipper can use the code with:
do "drop_anchor.pl";
die $@ if $@;
...
drop_anchor( ) if at_dock( ) or in_port( );
Thus, the code is brought into separate files to permit easy
maintenance and interprogrammer cooperation.
While the code brought in from a .pl file can have
direct executable statements, it's much more common
to simply define subroutines that can be called by the code
containing the do.
Going back to that drop_anchor.pl library for a
second, imagine what would happen if the Skipper wrote a program that
needed to "drop anchor" as well as
navigate:
do "drop_anchor.pl";
die $@ if $@;
do "navigate.pl";
die $@ if $@;
...
turn_towards_heading(90);
...
drop_anchor( ) if at_dock( );