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,..

In reply to Re: Re: regex 2 match C function by jai
in thread regex 2 match C function by jai

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.