my @pixels; #Read it into an array for my $x ($width) { for my $y ($height) { $pixels[$x][$y] = $bmp->xy( $x, $y ); } } print Dumper(@pixels); return ( $total_pixels, \@pixels ); OUTPUT OF THAT IS: [Image::BMP] ERROR: xy(5,8) is out of bounds [5x8] at Neural/Image.pm line 28 @pixels = ( undef, undef, undef, undef, undef, [ undef, undef, undef, undef, undef, undef, undef, undef, undef ] );