#!perl -w use strict; $/ = ';'; my ($header, $type, $arguments); for my $data (<DATA>) { $data =~ s/(((?:static\s+)?\w+)\s+(\w+)\s*\(([^)]*)\)\s*\{)/($3 eq 'if' or $3 eq 'do' or $3 eq 'while' o +r $3 eq 'for') ? +$1 : "\/* Function: $3()\n" . " Input:\n" . do { $header = $1; $type = $2; $arguments = $4 . ','; '' +} . (join "\n", map { sprintf " %-8s %8 +s : ", split } $arguments =~ m|\s*(\w+\**\s+\**\w+)\s*,|g) +. "\n\n" . " Output:\n" . (sprintf " %-8s : \n", +$type) . "\n Author :\n Date :\ +n*\/" . "\n\n$header"/ge; print $data; } __DATA__ int function(int a, char *b) { ... return 0; }
In reply to Re: regex 2 match C function
by CombatSquirrel
in thread regex 2 match C function
by jai
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |