#Encodes a hash/array ref to a bencoded string sub bEncode { my $dictref = $_[0]; my $retval = ''; #add this line my ($key, $value); if (ref($dictref) eq 'HASH') { ..... .....