home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / perl / 7472 < prev    next >
Encoding:
Internet Message Format  |  1992-12-16  |  1.4 KB

  1. Path: sparky!uunet!spool.mu.edu!uwm.edu!ogicse!reed!romulus!merlyn
  2. From: merlyn@ora.com (Randal L. Schwartz)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: Feature request for perl V
  5. Message-ID: <MERLYN.92Dec16172442@romulus.reed.edu>
  6. Date: 17 Dec 92 01:24:47 GMT
  7. Article-I.D.: romulus.MERLYN.92Dec16172442
  8. References: <62887@mimsy.umd.edu>
  9. Sender: news@reed.edu (USENET News System)
  10. Organization: Stonehenge Consulting Services; Portland, Oregon, USA
  11. Lines: 22
  12. In-Reply-To: folta@cs.umd.edu's message of 17 Dec 92 00:42:36 GMT
  13.  
  14. In article <62887@mimsy.umd.edu> folta@cs.umd.edu (Wayne Folta) writes:
  15.    Could grep have an added option/mode that would allow me to get an array
  16.    of indices instead of an array of items? I want to read a file into an
  17.    array, then do some greps in the array, some calculations, and then if
  18.    everything is right, make a couple of changes in the array, then write it
  19.    back out to the file. If I could do this:
  20.  
  21.       @line_numbers = grepi (/IN A/, @lines) ;
  22.  
  23.    I'd be pretty happy. How's it sound?
  24.  
  25. @line_numbers = grep($lines[$_] =~ /IN A/, $[ .. $#lines);
  26.  
  27. Be happy.
  28.  
  29. And stop asking for Perl 5 features!  Larry has a full plate as it is!
  30.  
  31. print grep(!/!/,"Just another Perl hacker,")
  32. --
  33. Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
  34. merlyn@ora.com (semi-permanent) merlyn@reed.edu (for newsreading only)
  35. factoid: "Portland, Oregon, home of the California Raisins and Lone-Star Beer!"
  36.