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

Thanks everyone. It is sorted now. :)
Was having a bit of a brain smerdge.
  • Comment on Re: sub will not return data correctly (the way i want it to!!)

Replies are listed 'Best First'.
Re^2: sub will not return data correctly (the way i want it to!!)
by mr_mischief (Monsignor) on Jun 18, 2015 at 01:01 UTC

    There's definitely more than one way to do it.

    use strict; use warnings; sub test { read( DATA, my $foo1, 0x04 ); return $foo1; } sub test_b { my @array; for my $i ( 0 .. 15 ) { read( DATA, $array[$i], 0x04 ); } return @array; } print "\ntest_1:\n"; print test() for ( 1..4 ); print "\ntest_2:\n"; print test() for 1..15, "\n"; print "\ntest_3:\n"; print test_b(), "\n" ; __DATA__ belongs to test1belongs to test2belongs to test2belongs to test2belong +s to test2belongs to test3belongs to test3belongs to test3belongs to +test3