Hey,

in short, this is your program:
foreach my $main(@sortcrit) {
              $main->{$sort_crit} = $empnames->{ $main->{$assigned} } if
($sort eq "assigned");

 foreach (@values) {
              $$_{$assigned} = $empnames->{ $$_{$assigned} };
              print "inner: $$_{$sort_crit}   outer:$$main{$sort_crit}<br>";
        }
}

Let's start by adressing your question:
the most likely reason that the 2nd loop is not printing anything is because
either $sort_crit is empty (unlikely in this case), or a non existant key,
so check that

further more, i cant see where some of your vars are defined, so i'm not
sure the problem lies there. So add a few print statements to double check
if your vars really hold what you think they do

now, on to some style issues:
first you use this:
$main->{$sort_crit}

then this:
$$_{$assigned}

now they both do the same thing, but let me point out, that it's concidered
'good programming praxis' to use the arrow notation.
also, it disambiguates, which might be something that you need in the future
(depending on what the script is used for)

here's just a pet peeve of mine, but i'd advice to write:
$main->{$sort_crit} = $empnames->{ $main->{$assigned} } if ($sort eq
"assigned")
as
if ($sort eq "assigned") { $main->{$sort_crit} =
empnames->{ $main->{$assigned} } }
i like my conditionals up front to remove confusion, but again, that's just
me and TIMTOWTDI


hth,

Jos Boumans


> inner: Kenny Szu outer:Joe madison Gray
> inner: Joe madison Gray outer:Joe madison Gray
> inner: Joe madison Gray outer:Joe madison Gray
> inner: Dan Maniotis outer:Joe madison Gray
> inner: outer:Dan Maniotis
> inner: outer:Dan Maniotis
> inner: outer:Dan Maniotis
> inner: outer:Dan Maniotis
> inner: outer:Kenny Szu
> inner: outer:Kenny Szu
> inner: outer:Kenny Szu
> inner: outer:Kenny Szu
>
> Any ideas as to why this is happening?

Reply via email to