my %hsh; @hsh{ /(\$[A-Za-z_]\w*)/g } = () while <>; delete $hsh{''}; # tidy up print $_, $/ for keys %hsh;