i think the inner block would be much clearer and short as something like this (note also that $a and $b should be avoided because of their use by
sort):
foreach (@FILE_ARRAY){
next unless /^(?:([0-9_a-zA-Z*]+) +)?(?:([0-9_a-zA-Z*]+) +)?(?:([0-9
+_a-zA-Z*]+) +)?([0-9_a-zA-Z*]+)\((.+?)\)/;
my ($args, @definition) = map { defined($_)?$_:'' } $5, $1, $2, $3,
+$3;
print join(" ", @definition) . " ARGS: $args\n";
}
This only works with parsing one row
To workaround this, you need to slurp in either the whole file, or maybe just one function (maybe defined by /^}$/ ?? not going to be 100%) at a time.. Then your regex can use the /s modifier and span multiple lines and you'll want to change all the spaces in the regex to \s+
Later Im gonna add for parsing Perl scripts aswell, but that is alot easier.
easier? really? There is
PPI, but there's set way to pass parameters into a function ... e.g.
sub foo {
my $self = shift;
my $p = {@_};
my $name = $p->{name} or die;
my $value = $p->{value} || 123;
}
But there's many other ways (
Super Search for threads on passing parameters) to do it, including mucking directly with @_