How do I populate a hash (that has been defined in a separate file) in my Perl script and do necessary operations on it? -


how populate hash (that has been defined in separate file) in perl script , necessary operations on it?

for ex:

file1.pl -- contains defined hash,

file2.pl -- user defined code should populate hash file1.pl

my %tgs = (     'articles' =>  {         'vim' => '20 awesome articles posted',         'awk' => '9 awesome articles posted',         'sed' => '10 awesome articles posted'     },      'ebooks' =>  {         'linux 101'   => 'practical examples build strong foundation in linux',         'nagios core' => 'monitor everything, proactive, , sleep well'     }, ); 

@gibron has answered question.
show code, may more interested.
way of populating ordinary hash same of populating 'hash on hash'.
i'm using data::dumper show hash structure directly, can choose own way know final hash contains.

use strict; use data::dumper qw(dumper); 'file1.def'; # evaluate file1  # add new sub key , value 'hash of hash' $file1::tgs{'articles'}{'emacs'} = '21 awesome articles posted';  # create new pair $file1::tgs{'new_key'}{'new_sub_key'} = 'new_value';  # see result print dumper (\%file1::tgs); 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -