#!perl -w use strict; undef $/; my ($header, $type, $arguments); my $file = ; $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", $type) . "\n Author :\n Date :\n*\/" . "\n\n$header"/ge; print $file; __DATA__ int function(int a, char *b) { ... return 0; }