in reply to Dereference a reference to a file handle created with IO::File

print can be used as follows:

print $SCALAR LIST print $SCALAR print BLOCK LIST print BLOCK print LIST print

You have the following:

print $ads{$this_ad} "$line\n";

$ads{$this_ad} doesn't match $SCALAR or BLOCK, so this must be print LIST. But that's not what you want. Replace what you have with

print { $ads{$this_ad} } "$line\n";
or
$ads{$this_ad}->print("$line\n");