home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / perl / 5550 < prev    next >
Encoding:
Text File  |  1992-08-27  |  1.2 KB  |  40 lines

  1. Path: sparky!uunet!dtix!darwin.sura.net!mips!odin!sierra.corp.sgi.com!stantz
  2. From: stantz@sierra.corp.sgi.com (Mark Stantz)
  3. Newsgroups: comp.lang.perl
  4. Subject: 4.035 bug or feature...why does this run?
  5. Message-ID: <1992Aug27.171036.28995@odin.corp.sgi.com>
  6. Date: 27 Aug 92 17:10:36 GMT
  7. Sender: news@odin.corp.sgi.com (Net News)
  8. Organization: Silicon Graphics, Inc.
  9. Lines: 28
  10. Nntp-Posting-Host: sierra.corp.sgi.com
  11.  
  12.  
  13.     Consider the following trivial perl program, which computes the
  14. union of two sets of strings:
  15.  
  16.  
  17. #!/usr/local/bin/perl
  18.  
  19. @s1 = ("just", " another ");
  20. @s2 = ("perl", " hacker", "\n");
  21.  
  22. @u = @s1;
  23. foreach $item (@s2) {
  24.   push(@u, $item) unless (grep(($_ eq $item), @s1))        # Huh?
  25. }
  26.  
  27. print @u;
  28.  
  29.  
  30.     Why does this program run when there is no ';' at the end of 
  31. the line indicated with the comment?  Apparently it works fine under 4.035, 
  32. but doesn't run under 4.019 or earlier versions.  I would have expected the 
  33. 'doesn't run' behavior in 4.035 as well.
  34.  
  35.     What's the story behind this?
  36.  
  37. ------------------------------------------------------------------------------
  38. Mark Stantz    |      "...And on the seventh day, it was Miller Time..."
  39. stantz@sgi.com |                 -- Guinessis
  40.