cheanged av_top_index to av_len as it's the same but works with older perls