in reply to Undefined Error

use  @{ $searches{$conn} || [] }

The explanation

$ perl -le " use strict; use diagnostics; my $peter; print scalar @$pe +ter; Can't use an undefined value as an ARRAY reference at -e line 1 (#1) (F) A value used as either a hard reference or a symbolic referenc +e must be a defined value. This helps to delurk some insidious errors. Uncaught exception from user code: Can't use an undefined value as an ARRAY reference at -e line +1.

On explanation Basic debugging checklist (with Read this if you want to cut your development time in half! )