in reply to Hash to Scalar Assignment Oddity
In list context, the hash returns
('one', 1, 'two', 2, 'three', 3)
(but not necessarily in that order). So
print(%db, "\n");
is the same as
print('one', 1, 'two', 2, 'three', 3, "\n");
When you pass a list to print, it does
join($,, LIST)
So the above print is equivalent to
print(join($,, 'one', 1, 'two', 2, 'three', 3, "\n"));
However, in scalar context, the hash some information about its buckets. To do emulate the
behaviour of print, do
$db = join($,, %db);
|
|---|