home *** CD-ROM | disk | FTP | other *** search
/ ftp.cse.unsw.edu.au / 2014.06.ftp.cse.unsw.edu.au.tar / ftp.cse.unsw.edu.au / pub / doc / languages / perl / nutshell / ch2 / fun2text < prev    next >
Encoding:
Text File  |  1992-10-18  |  413 b   |  20 lines

  1. #!/usr/bin/perl
  2.  
  3. # Initialize @fun2text, a normal array.
  4. # (Use $fun2text[$function] to find the text.)
  5.  
  6. @fun2text = (
  7.     "Update",
  8.     "Acknowledgement",
  9.     "Lightning",
  10.     "Sabeans",
  11.     "Chaldeans",
  12.     "Page Servant",
  13. );
  14.  
  15. # Initialize %text2fun, an associative array, by inversion.
  16. # (Use $text2fun{$text} to find the function code.)
  17.  
  18. $index = 0;
  19. foreach $text (@fun2text) { $text2fun{$text} = $index++; }
  20.