in reply to Newbie question, advice appreciated
#!/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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Newbie question, advice appreciated
by sauoq (Abbot) on Sep 27, 2005 at 23:46 UTC |