my $csrc; { local $/; # slurp the source code $csrc = <>; # from stdin or $ARGV[0] } while ( $csrc =~ /\n((?:\w+\*?\s+)+) (\w+\s*) \( (.*?) \) \s* \{ /gsx ) { my ( $functype, $funcname, $funcarg ) = ( $1, $2, $3 ); my @funcargs = split /,\s*/, $funcarg; print "found function def:\n type=$functype\n name=$funcname\n args=\n "; print join( "\n ", @funcargs ), "\n"; # do other stuff with these strings... }