Online Learning Applications for Technical English


Home
Syllabus
Assignments

Instructor



Producing Homepages

We can divide a program into subroutines. This is useful for organizing long programs or collecting blocks of code that are used many times. The subroutine code is specified using the keyword sub. Use the ampersand to call the subroutine name. For example:
  if( $student_id_num eq '' )
  {
    &id_error( );          # Call subroutine for printing error message 
  }

#-------------
# Subroutines
#-------------
  sub id_error
  {
    print "Content-type:  text/html\n\n";
    print <<END;
<HTML>
<HEAD>
</HEAD>
<BODY>
  Please input your student ID #.
</BODY>
</HTML>
END
  }

[ Back ]