in reply to Assigning Hash to Hash

What you need are references. The crucial line is this one

$date_class_room{$s_date} = %class_room;
which should instead be
$date_class_room{$s_date} = \%class_room;
The rest of your code you can keep pretty much the same, although I have to say storing the contents of a hash (%class_room) into an array (@x) and then into another hash (%b) is kind of a weird thing to do, but it will work. The only thing you need to change is the line where you assign to @x:
@x = %{$date_class_room{$_}};
What this means is that because up above we stored a reference to a hash as the value in our main hash, we can use the %{} construct to turn that reference back into a real hash - in this case, to produce a list of keys and values. The link above points to a tutorial on this and you can also look in Tutorials.

As a personal quip, if it were up to me, $scalar = %hash would either do the same thing as $scalar = \%hash or be a compile-time error.

Replies are listed 'Best First'.
Re^2: Assigning Hash to Hash
by shilpam (Sexton) on Nov 29, 2005 at 05:52 UTC
    Thanks a lot! I had tried using reference but then did not assign the value to @x properly. Now, I know where I went wrong. As for ur other comment on "storing the contents of a hash (%class_room) into an array (@x) and then into another hash (%b) is kind of a weird thing to do,"....Well, that was just one of my trial & error code which I just accidently pasted. Thanks again.