in reply to question to a complex structure of hash/array

Hello buchi2,

Can you provide us a working / compiling piece of code. I would like to test your code but I am not able because I am missing parts.

Regarding the for loop that you have...you can write it in a Perl way also:

for ($i = 0; $i <= $#yfeld; $i++)

Assuming that $#yfeld is an array @yfeld.

for my $i (0 .. $#yfeld)

I also do not understand why you instantiate $ii = -1; and on the next step 3 lines after you are adding 1 $ii = $ii + 1; which will result to 0. You can get this value from your for loop why you need to apply this calculation? Unless I am missing something here, that is hidden in the rest of the code that is missing.

Looking forward to your update, BR

Seeking for Perl wisdom...on the process of learning...not there...yet!

Replies are listed 'Best First'.
Re^2: question to a complex structure of hash/array
by buchi2 (Acolyte) on Aug 09, 2017 at 08:02 UTC
    Hello!

    >I also do not understand why you instantiate $ii = -1; and on the next step 3 lines after you are adding 1 $ii = $ii + 1; which will result to 0. You can get this value from your for loop why you need to apply this calculation?

    I removed this now with $ii and $i and use only $i.
    I had e.g. (0 1 2 3 0 0 0 7 0 9) as an input and my first try was, to keep these structure and take another structure, which only contain the places, which are not 0.

    Regards, buchi