If not P::RD, at least a more statefull parser rather than trying to do everything with just a single regex. Something like (and this is really rough and presumes curlies won't be on the same line as a declaration):
my $state = 'declaration';
my( $name, %data );
while( <> ) {
if( $state eq 'declaration' ) {
if( /CALCON\((.*?)\)/ ) {
$name = $1;
$state eq 'opencurly';
next;
}
}
if( $state eq 'opencurly' ) {
$state = 'body' if /{/;
}
if( $state eq 'body' ) {
if( /(\S+)\(.*?\)\s*$/ ) {
$data{ $name }->{ $1 } = $2;
}
if( /\s*}\s*$/ ) {
$state = 'declaration';
}
}
}
--
We're looking for people in ATL
|