in reply to Re: sub will not return data correctly (the way i want it to!!)
in thread sub will not return data correctly (the way i want it to!!)

Oh, ok i was unaware of that until now. I guess i will push all data onto an array then as said in CB.
  • Comment on Re^2: sub will not return data correctly (the way i want it to!!)

Replies are listed 'Best First'.
Re^3: sub will not return data (after data has been returned)
by jeffa (Bishop) on Jun 18, 2015 at 00:33 UTC

    You can also call the function 4 times instead:

    my @test_1_data = test_1($test); my @test_2_data; push @test_2_data, test_1( $test ) for 1 .. 4;
    Notice that test_2() is not even called. A for loop around the first sub accomplishes the same goal.

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
      thats wild that it doesnt even need test_2() called. I tried it and it did work, but why does it work even when test_2() isnt called? I will more than likely use this, otherwise I will have to change up abunch of code.
      EDIT: i found another problem as well ;) I also am converting the data to its hex equivalent with unpack('H*', ()).

      Why does this fail:
      push @test_2_data, unpack('H*', (test_2( $test ))) for 1 .. 4; print $_ for(@test_2_data);

      And this works:
      push @test_2_data, test_2( $test ) for 1 .. 4; for(@test_2_data){ $_ = unpack('H*', $_); } print $_ for(@test_2_data);