Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Scanning a plsql package body to make package headers... regexp requested

by sachmet (Scribe)
on Mar 28, 2001 at 03:02 UTC ( [id://67674]=note: print w/replies, xml ) Need Help??


in reply to Scanning a plsql package body to make package headers... regexp requested

Close...
#!/usr/bin/perl -w use strict; my $file = shift or die "must supply body file"; open F, $file; my $text = join '', <F>; my $regex = '(procedure|function)\b(.*?)\((.*?)\)'; while ($text =~ /$regex/mgs) { print $1,$2,"($3);",$/; }
The m is important to enable multi-line matching, or your regex will not scan across newlines.
  • Comment on Re: Scanning a plsql package body to make package headers... regexp requested
  • Download Code

Replies are listed 'Best First'.
Re: Re: Scanning a plsql package body to make package headers... regexp requested
by princepawn (Parson) on Mar 28, 2001 at 03:26 UTC
    Actually m made no difference in output. And what I had was working, it's just that the word "function" was in a comment and my regexp was lapping it up, so I will simply filter comments from the text before parsing it:
    #!/arudev/bin/perl use strict; my $file = shift or die "must supply body file"; open F, $file; my @text = <F>; my $text = join '', grep { ! /\s+\-{2,}/ } @text; my $regex = '(procedure|function)\b(.*?)\((.*?)\)'; while ($text =~ /$regex/gs) { print "*$1+$2-$3*",$/; }
    Prince "I knew I was the regexp overlord" Pawn

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://67674]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-26 01:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found