home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / perl / 5434 < prev    next >
Encoding:
Internet Message Format  |  1992-08-22  |  1.7 KB

  1. Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!malgudi.oar.net!uoft02.utoledo.edu!jupiter!steiner
  2. Newsgroups: comp.lang.perl
  3. Subject: questions
  4. Message-ID: <1992Aug22.163911.9640@uoft02.utoledo.edu>
  5. From: steiner@jupiter.cse.utoledo.edu (jason "Think!" steiner)
  6. Date: 22 Aug 92 16:39:10 EST
  7. Nntp-Posting-Host: jupiter.cse.utoledo.edu
  8. Lines: 34
  9.  
  10. i discovered pearl last week, printed out the man pages & have been
  11. experimenting a bit. it's a great language, but being such a newbie
  12. i tend to make some mistakes/assumptions that i should be able to
  13. avoid...
  14.  
  15. here's one of many questions:
  16.  
  17. i have a search line like
  18.  
  19.         $line =~ /^(.{0,$limit}[${spacechars}])(.*)$/;
  20.  
  21. which grabs as many words as can fit in $limit space + the next separator
  22. into $1 and puts the rest in $2. just in case there isn't a separator
  23. in the limit the next line is
  24.  
  25.         $line =~ /^(.{0,$limit})(.*)$/ unless $1;
  26.  
  27. (just grab $limit characters, don't worry about separators.)
  28. this is assuming that the first match will set $1 to null or undefined
  29. if it doesn't get anything. can i do that? it seemed reasonable to
  30. me, but then the second case kept failing. i printed $1 between the
  31. two statements & it had the value of a $1 from earlier in the script.
  32. does match just ignore the $[1-9] values if they're not found?
  33.  
  34. the script works now, (i clear $1 before doing the matches) i'm just kinda
  35. curious.
  36.  
  37. jason, who can now hit * in vi and wordwrap everything while maintaining
  38. followup quotes and trimming attribution lines.
  39.  
  40. --
  41. `,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,
  42. `, "Get off the cross. We need the wood." steiner@jupiter.cse.utoledo.edu `,
  43. `,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,
  44.