in reply to subroutine array empty

instead of

sub getSongs { my $dir = @_; # INCORRECT: assigns @_ in SCALAR context ... } # end of subroutine definition

try

my ($dir) = @_; # assign @_ in list context