in reply to Stumped with $_ being modified
# Right here, $_ contains "nm : $tag" from the tagheader() # I see that $_ has been modified by tagheader() # This is my problem and I'm stumped :(O.k., that's simple enough to fix:
PS: ++ to you for using strict.{ 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 (<STYLESHEET>) { 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} } }
jdporter
The 6th Rule of Perl Club is -- There is no Rule #6.
|
|---|