in reply to regex 2 match C function
#!perl -w use strict; undef $/; my ($header, $type, $arguments); my $file = <DATA>; $file =~ s/((\w+)\s+(\w+)\s*\(([^)]*)\)\s*\{)/"\/* Function: $3()\n" . " Input:\n" . do { $header = + $1; $type = $2; $arguments = $4 . ','; ''} . (join "\n", map { sprintf " + %-5s %8s : ", split } $arguments =~ m|\s*(\w+\**\s+\**\w+) +\s*,|g) . "\n\n" . " Output:\n" . (sprintf " %-5s : \n", $ty +pe) . "\n Author :\n Date :\n*\ +/" . "\n\n$header"/ge; print $file; __DATA__ int function(int a, char *b) { ... return 0; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: regex 2 match C function
by jai (Sexton) on Aug 14, 2003 at 06:33 UTC |