in reply to pattern matching c-style function definitions :o(
As noted in the code, you might have to check for structs and/or classes.my ($prev, $type, $func, $args, $body); while (<>) { if (/^\{/) { # maybe check for structs/classes here if necessary ($type, $func, $args) = split(' ', $prev, 3); $body = ''; } elsif (/^\}/) { # ... process the function here ... $func = undef; } else { if (defined($func)) { $body .= $_; } else { $prev = $_; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: pattern matching c-style function definitions :o(
by barryscott (Acolyte) on Jan 07, 2008 at 20:39 UTC |