in reply to sub routine trouble
Two problems, one hidden by your order of definition.
The hidden one is from the use of an empty prototype. Properly ordered, your code would fail when you gave arguments to the sub. As it is, with warnings on, you would see the "Too late for prototype. . ." message.
When you say %paramhash = %$params1;, you are making a copy of the hash referenced by the argument. Manipulate directly through the reference to make your sub mutate the external structures.
I've taken care to make the variables lexical. There is no reason to have all those internal variables lurking in your namespace. Using strict and warnings will improve your code. Not knowing your intent, I copied your program logic directly.sub upd_info { my ($hashref, $aryref) = @_; for my $key (keys %$hashref) { my $upd_flag = 0; for (sort @$aryref) { if ( /^\Q$key\E\s+(\w+)$/ ) { $upd_flag++; $hashref->{$key} .= $1; last; } } $upd_flag or $hashref->{$key} .= ' NONE'; } 1; }
After Compline,
Zaxo
|
|---|