in reply to Re^2: 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!!)

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)

Replies are listed 'Best First'.
Re^4: sub will not return data (after data has been returned)
by james28909 (Deacon) on Jun 18, 2015 at 00:59 UTC
    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);