my $input; unless ( $input = shift ) { # read from DATA my @tunes = grep { $_ !~ /^#/ and /\S/ } ; chomp($input = $tunes[rand(@tunes)]); }