home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!asuvax!ncar!csn!cherokee!lookout.it.uswc.uswest.com!rray
- From: rray@lookout.it.uswc.uswest.com (Randy J. Ray)
- Subject: Using $*, but pattern doesn't match
- Message-ID: <1992Aug25.181818.13613@advtech.uswest.com>
- Sender: rray@snakepit (Randy J. Ray)
- Nntp-Posting-Host: snakepit.it.uswc.uswest.com
- Organization: US WEST Communications, Inc. -- Denver, CO
- Date: Tue, 25 Aug 1992 18:18:18 GMT
- Lines: 41
-
- I am trying to match a multi-line pattern. I have set $* in the subroutine that
- is performing the match. I have a string called $body that contains several
- lines of perl code, read in from a file. The lines are newline-terminates (I
- did not chop them). An example value of $body would be:
-
- local(*logflag, *syntax_OK, *prj, *rls1, *rls1_tar, *rls2, *rls2_tar,
- *pltfrm) = @_;
-
- .
- . [deleted for breveity]
- .
-
- $syntax_OK = 1;
- return(1);
-
- The whole text is not important; it is the body of a subroutine, after the
- "sub <name> {" and before the ending "}". To this string, I am doing a search:
-
- $body =~ /$SUBARGS/o
-
- Where $SUBARGS is a pseudo-constant (it is known to never change), hence the
- 'o' modifier. The value of $SUBARGS is:
-
- ^\s+local\s*\((.*)\)\s*=\s*\@_\s*;
-
- Which *should* match the local() declaration that handles the passed arguments
- to said subroutine, leaving the list of arguments in $1. It works fine if the
- local() declaration is on one line, but with the above example it fails to
- match. I thought that ".* would match anything (up to a final ")" in this case)
- with $* set to 1?
-
- No stylistic flames, please. This tool is written to do analysis on perl
- scripts developed with a specific set of coding standards.
-
- Randy
- --
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Randy J. Ray -- U S WEST IT/CSD rray@{lookout,uswat}.it.uswc.uswest.com
- I'd rather talk religion with Charles Manson than discuss ethics with Congress.
- -me Phone: (303)595-2852
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-