hi,
thanx for the code. actually i came up with the following.
foreach (@ARGV) {
# Read file
open(FF,"<$_") || die ("Cant open $_ : $!\n");
my $t=<FF>;
close FF;
$t=~s/((\**\s*\w+\s*)+\s*)(\((\s*\**\s*\w+,?)*\)?\s*{)/${\&do(
+$1,$3)}/g;
# Write file
open (FF, ">$_.j") || die ("Cant open $_.j : $!\n");
print FF $t;
close FF;
}
sub do($$) {
my ($a,$b)=@_;
my ($t1, $t2, @t3);
$t1=$a,$t2=$b;
$a=~s/\n/ /gm;
$b=~s/\n//g;
$b=~s/\s+/ /gm;
$b=~s/[(\{)]/ /g;
@t3=split /,/,$b;
#@t3=map {"\n *$_\t : " } @t3;
@t3=map{sprintf "\n *%-13s : ", $_} @t3;
my $t=<<E;
/*
* Function : $a
*
* Inputs : \n *@t3
*
* Author :
* Date :
*/
$t1$t2
E
}
I know urs is far better. as u said, it will match try, catch blocks and also constructs of type
#define add(x,y) {\
I'd like the monks to give suggestions on optimizations,.. |