[Image of Linux]
Linux's Witness Ministry
The Personal Web Pages of Chris X. Edwards

ex-sub.pl

--------------------------
#!/usr/bin/perl 
#ex-sub.pl
#subroutine is a piece of code isolated from the rest of the program

sub eieio;  #declares a subroutine for definition later
            #can use it BEFORE you define it 

@A=("cat", "ant", "whitefly", "bandicoot", "wallaby");
foreach $a (@A){
  print "old mac donald had a farm\n";
  eieio;
  print "and on this farm he had a ", $a, "\n";
  eieio; 
  print "\n";
} #end of foreach control block


sub eieio { #now we define our subroutine
  print "E-I-E-I-O\n";
} #end of eieio subroutine


--------------------------
Return to Program Examples
This page was created with only free, open-source, publicly licensed software.
This page was designed to be viewed with any browser on any system.
Chris X. Edwards ~ January 2003