#!/usr/bin/perl -w use strict; # open(DATA,"file.txt") or die $!; # I am using DATA handle but you can open a file to read contents too. my %functions; while () { chomp; my @functxt = (); my $desc = (); if (/STANDARD/) { @functxt = split /\s+/; $desc = ; $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 #### func1 : func1 does something funny func3 : func3 is a math function func2 : func2 does something useful