in reply to Overwriting Hash / Array

The variable @columns_import is only declared within your 1..$scheduled_export_days loop and will be initialized anew on every trip through that loop.

A different variable of the same name is used outside of that loop.

Either you are not using the strict pragma, which would have alerted you to the situation of an undeclared variable being used, or you have declared the variable in two places.

Replies are listed 'Best First'.
Re^2: Overwriting Hash / Array
by iRemix94 (Sexton) on Jul 28, 2015 at 08:02 UTC

    I'm sorry, that was something I changed before to try some things, I updated the code so it reflects exactly how it works at the moment! The @columns_import array should be outside of the named loop, you are right. Do you have any idea how to get the overwritten array fixed?

      The @columns_import array is not the problem. You are modifying the %column_data_import; hash but always keep the same variable around. Most likely, the line my %column_data_import; must be moved into the loop where the different column data import schedules are held.

        If I do that, i have to put the line into the loop aswell:

        push (@columns_import, \%column_data_import);

        this results in a data structure with wrong data in it, as you can see in the Dumper result here:

        { 'IMPORT_VALUE' => '1', 'BGCOLOR_CUSTOMER' => 0, 'SCHEDULE_ROWS' => [ { 'SCHEDULE_COLUMNS_EXPORT' => [ { 'S +CHEDULE' => '20:00', 'U +NDEF' => 1 }, { 'L +INK' => 'CUSTOMERA_DOMAINA_27.07.2015_20_EXPORT.html', 'O +K' => 1, 'S +CHEDULE' => '20:00', 'U +NDEF' => 0 }, { 'L +INK' => 'CUSTOMERA_DOMAINA_26.07.2015_20_EXPORT.html', 'O +K' => 1, 'S +CHEDULE' => '20:00', 'U +NDEF' => 0 }, { 'L +INK' => CUSTOMERA_DOMAINA_25.07.2015_20_EXPORT.html', 'O +K' => 1, 'S +CHEDULE' => '20:00', 'U +NDEF' => 0 }, { 'S +CHEDULE' => '20:00', 'U +NDEF' => 1 }, { 'S +CHEDULE' => '20:00', 'U +NDEF' => 1 }, { 'S +CHEDULE' => '20:00', 'U +NDEF' => 1 } ] }, { 'SCHEDULE_COLUMNS_IMPORT' => [ { 'S +CHEDULE' => '23:21', 'U +NDEF' => 1 }, {}, {}, { 'S +CHEDULE' => '23:42', 'U +NDEF' => 1 }, {}, { 'S +CHEDULE' => '23:21', 'U +NDEF' => 1 }, {}, {}, { 'S +CHEDULE' => '23:42', 'U +NDEF' => 1 }, {}, { 'S +CHEDULE' => '23:21', 'U +NDEF' => 1 }, {}, {}, { 'S +CHEDULE' => '23:42', 'U +NDEF' => 1 }, {}, { 'S +CHEDULE' => '23:21', 'U +NDEF' => 1 }, {}, {}, { 'S +CHEDULE' => '23:42', 'U +NDEF' => 1 }, {}, { 'S +CHEDULE' => '23:21', 'U +NDEF' => 1 }, {}, {}, { 'S +CHEDULE' => '23:42', 'U +NDEF' => 1 }, {}, { 'S +CHEDULE' => '23:21', 'U +NDEF' => 1 }, {}, {}, { 'S +CHEDULE' => '23:42', 'U +NDEF' => 1 }, {}, { 'S +CHEDULE' => '23:21', 'U +NDEF' => 1 }, {}, {}, { 'S +CHEDULE' => '23:42', 'U +NDEF' => 1 }, {} ] } ], 'EXPORT_VALUE' => '1', 'DOMAIN' => 'DOMAINA', 'CUSTOMER' => 'CUSTOMERA' },