in reply to sub routine trouble

You're updating a copy of the hashes.

Fix alternative 1:

sub upd_info { # Create non-reference aliases to arguments. our %paramhash; local *paramhash = shift; our @paramarray; local *paramarray = shift; ... keep rest as is ... }

Fix alternative 2:

sub upd_info { my ($paramshash, $paramarray) = @_; while (($key, $val) = each(%$paramhash)) # added $ { $upd_flg = 0; foreach $item (sort { $a cmp $b } @$paramarray) # added $ { if ($item =~ /^$key\s+(\w+)$/) { $upd_flg = $upd_flg + 1; $paramhash->{$key} .= " $1"; # added -> last; } } if ($upd_flg == 0) { $paramhash->{$key} .= " NONE"; # added -> } }

btw, you're gonna get yourself into trouble sooner or later if you don't tighten the scope of your local variables by using my (my $key; my $val; my $item;, etc) It's best if you use use strict;, which will rightfully complain about these variables.

Replies are listed 'Best First'.
Re^2: sub routine trouble
by tc1364 (Beadle) on Dec 10, 2004 at 19:14 UTC
    It is a blessing to be able to ask someone of your ablities for some help. The code works great now. Thank you very much for your time and consideration regarding this subject matter.