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 / ch3 / switches < prev   
Encoding:
Text File  |  1992-10-18  |  649 b   |  39 lines

  1. #!/usr/bin/perl
  2.  
  3. FOO: {
  4.     if (/^abc/) { $abc = 1; last FOO; }
  5.     if (/^def/) { $def = 1; last FOO; }
  6.     if (/^xyz/) { $xyz = 1; last FOO; }
  7.     $nothing = 1;
  8. }
  9.  
  10. FOO: {
  11.     $abc = 1, last FOO  if /^abc/;
  12.     $def = 1, last FOO  if /^def/;
  13.     $xyz = 1, last FOO  if /^xyz/;
  14.     $nothing = 1;
  15. }
  16.  
  17. FOO: {
  18.     /^abc/ && do { $abc = 1; last FOO; };
  19.     /^def/ && do { $def = 1; last FOO; };
  20.     /^xyz/ && do { $xyz = 1; last FOO; };
  21.     $nothing = 1;
  22. }
  23.  
  24. FOO: {
  25.     /^abc/ && ($abc = 1, last FOO);
  26.     /^def/ && ($def = 1, last FOO);
  27.     /^xyz/ && ($xyz = 1, last FOO);
  28.     $nothing = 1;
  29. }
  30.  
  31. if (/^abc/)
  32.     { $abc = 1; }
  33. elsif (/^def/)
  34.     { $def = 1; }
  35. elsif (/^xyz/)
  36.     { $xyz = 1; }
  37. else
  38.     {$nothing = 1;}
  39.