Hopefully Anonymous Monk's advice fixes your problem, but to explain your error message a litte, when you printed $RV and got the "Use of uninitialized value ..." warning, that was because $RV was undef after the testJPG() call, and the perl -w switch is on. This is kind of a trivial case, but note that if you wanted a pretty, warning-less debug statement, you could do something like:
use Data::Dumper;
print Dumper $RV;
# or
printf "RV: %s\n", defined $RV ? $RV : 'UNDEF';
# or even (to make sure $RV is always defined:
my $rv = Image::TestJPG::testJPG($jpgData, $length) || 0;