local $_; #### { my %tags; # here's where we load the %tags: open STYLESHEET, '< stylesheet.txt' or die "Error opening stylesheet.txt: $!"; ########################################################### # "HEADER" appears before "nm" in the style sheet # Find each "HEADER" in the file and assign $1 to $header # If we find the $tag we're looking for return $header # local $_; my $header; while () { if ( /^HEADER (\d+):/ ) { $header = $1; } elsif ( /^nm : (\w+)/ ) { $tags{$1} = $header; } } close STYLESHEET; # and here's the function we call to look up a tag: sub tagheader { my $tag = shift; $tags{$tag} } }