home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / perl / 5377 < prev    next >
Encoding:
Text File  |  1992-08-18  |  1.4 KB  |  53 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!boulder!ucsu!spot.Colorado.EDU!farnham
  3. From: farnham@spot.Colorado.EDU (Farnham Dave)
  4. Subject: Bug with $number variables ???
  5. Message-ID: <1992Aug19.040708.519@ucsu.Colorado.EDU>
  6. Sender: news@ucsu.Colorado.EDU (USENET News System)
  7. Nntp-Posting-Host: spot.colorado.edu
  8. Organization: University of Colorado, Boulder
  9. Date: Wed, 19 Aug 1992 04:07:08 GMT
  10. Lines: 41
  11.  
  12.  
  13. Consider the small code fragment below:
  14.  
  15.     ---------------------------------------------
  16.     $search_str = "^farnham:";
  17.  
  18.     open (PASS, "/etc/passwd");
  19.  
  20.     while ($line = <PASS>) {
  21.         if ($line =~ /($search_str).*:.*:.*:.*:.*:(.*)$/) {
  22.             ($login = $1) =~ s/:$//;  # remove ':'
  23.             $shell = $2;
  24.             print "Name <$login>   Shell <$shell>\n";
  25.         }
  26.     }
  27.     ---------------------------------------------
  28.  
  29. The two lines I'm referring to are:
  30.     ($login = $1) =~ s/:$//;  # remove ':'
  31.     $shell = $2;
  32.  
  33. In PL-35 "$2" has vanished.  It appears that after a
  34. substitute all the $number variables get reset to null
  35. even if I don't do another capture.
  36.  
  37. This wasn't the case in PL-19.  Was I abusing PL-19 or
  38. did something break?
  39.  
  40.  
  41. Thanks,
  42.  
  43.  
  44. Dave
  45.  
  46. ================================================================
  47. Dave Farnham
  48. Ball Aerospace
  49. Electro-Optical/Cryogenics Division  "Why is my office so cold?"
  50. P.O. Box 1062
  51. Boulder, CO  80306    (303) 939-5515
  52. { farnham@spot.colorado.edu, farnham@handel.cs.colostate.edu }
  53.