while (my $line = ) { $line =~ s/(\S+)/$dict{$1} || $1/eg; print $line; }