I am not sure if i completely understand the spec. Here is my shot at this. I have put the data at the end so you can see if it is structured in that way.
#!/usr/bin/perl -w
use strict;
# open(DATA,"file.txt") or die $!; # I am using DATA handle but you c
+an open a file to read contents too.
my %functions;
while (<DATA>) {
chomp;
my @functxt = ();
my $desc = ();
if (/STANDARD/) {
@functxt = split /\s+/;
$desc = <DATA>;
$functions{pop(@functxt)} = $desc; # assuming last word is
+function name
}
}
print +($_, " : ", $functions{$_}, $/) for (keys %functions);
__DATA__
# STANDARD func1
func1 does something funny
blah
blah
ok
junk text
# STANDARD func2
func2 does something useful
# STANDARD func3
func3 is a math function
output
func1 : func1 does something funny
func3 : func3 is a math function
func2 : func2 does something useful