in reply to Converting Excel to Hash

What does your code output?

What output do you expect instead?

Replies are listed 'Best First'.
Re^2: Converting Excel to Hash
by ravi179 (Novice) on Jan 03, 2017 at 08:40 UTC

    Expected Output

    { '1'=> { 'clz=>'nit' 'degree'=>'ph.d', 'name'=>'teja' }, '1'=> { 'clz=>'iit' 'degree'=>'M.tech', 'name'=>'teja' },####This block not coming in output '2'=>{ 'clz=>'mit' 'degree'=>'ravi', 'name'=>'B.Tech' } };

      A hash cannot have multiple values for the same key. You will need to rethink your data structure.

      Consider storing array references as values instead of hash references as values:

      { '1'=> [{ 'clz=>'nit' 'degree'=>'ph.d', 'name'=>'teja' }, { 'clz=>'iit' 'degree'=>'M.tech', 'name'=>'teja' }],####This block not coming in output '2'=>[{ 'clz=>'mit' 'degree'=>'ravi', 'name'=>'B.Tech' }] };

      This change will also need changes in your code on how you fill the data structure and how you output your data structure.

        I am new to perl. Could you please guide me how to achieve that.Thanks in advance.