in reply to How can I populate attributes of a hash into another ?
As others have also pointed out, you cannot transparently 'inherit' one hash from another; but wouldn't
print $chapter{book}{name};
Be both acceptable and superior as its clear that it's the book's name, not the chapter's name, being printed
(Also, you could then use 'title' for both the title of the book and the title of the chapters if you wanted to):
#! perl -slw use strict; my %book = ( 'name' => 'abc', 'author' => 'monk', 'isbn' => '123-890', 'issn' => '@issn', ); my %chapter = ( 'book' => \%book, 'title' => 'xyz', 'page' => '90', ); print $chapter{book}{name}; __END__ C:\test>junk82 abc
|
|---|