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

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!asuvax!ncar!csn!cherokee!lookout.it.uswc.uswest.com!rray
  3. From: rray@lookout.it.uswc.uswest.com (Randy J. Ray)
  4. Subject: Using $*, but pattern doesn't match
  5. Message-ID: <1992Aug25.181818.13613@advtech.uswest.com>
  6. Sender: rray@snakepit (Randy J. Ray)
  7. Nntp-Posting-Host: snakepit.it.uswc.uswest.com
  8. Organization: US WEST Communications, Inc. -- Denver, CO
  9. Date: Tue, 25 Aug 1992 18:18:18 GMT
  10. Lines: 41
  11.  
  12. I am trying to match a multi-line pattern. I have set $* in the subroutine that
  13. is performing the match. I have a string called $body that contains several
  14. lines of perl code, read in from a file. The lines are newline-terminates (I
  15. did not chop them). An example value of $body would be:
  16.    
  17.     local(*logflag, *syntax_OK, *prj, *rls1, *rls1_tar, *rls2, *rls2_tar,
  18.            *pltfrm) =  @_;
  19.  
  20.     .
  21.     . [deleted for breveity]
  22.     .
  23.  
  24.     $syntax_OK = 1;
  25.     return(1);
  26.  
  27. The whole text is not important; it is the body of a subroutine, after the 
  28. "sub <name> {" and before the ending "}". To this string, I am doing a search:
  29.  
  30. $body =~ /$SUBARGS/o
  31.  
  32. Where $SUBARGS is a pseudo-constant (it is known to never change), hence the
  33. 'o' modifier. The value of $SUBARGS is:
  34.  
  35. ^\s+local\s*\((.*)\)\s*=\s*\@_\s*;
  36.  
  37. Which *should* match the local() declaration that handles the passed arguments
  38. to said subroutine, leaving the list of arguments in $1. It works fine if the
  39. local() declaration is on one line, but with the above example it fails to
  40. match. I thought that ".* would match anything (up to a final ")" in this case)
  41. with $* set to 1?
  42.  
  43. No stylistic flames, please. This tool is written to do analysis on perl
  44. scripts developed with a specific set of coding standards.
  45.  
  46. Randy
  47. -- 
  48. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  49. Randy J. Ray -- U S WEST IT/CSD         rray@{lookout,uswat}.it.uswc.uswest.com
  50. I'd rather talk religion with Charles Manson than discuss ethics with Congress.
  51.      -me                                                   Phone: (303)595-2852
  52. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  53.