if ( defined($hash{$key}) && hash{$key} =~ m/\w+/ ) { $hash{$key} = "Numbers: " . $hash{$key}; } #### #!/usr/bin/perl use warnings; use strict; my %hash = (); $hash{a} = "123"; $hash{b} = "456"; $hash{c} = "789"; my $key = "c"; if ( defined($hash{$key}) && hash{$key} =~ m/\w+/ ) { $hash{$key} = "Numbers: " . $hash{$key}; } print $hash{$key}, "\n"; #### C:\>perl -cw bareword.pl bareword.pl syntax OK C:\>perl bareword.pl Can't locate object method "hash" via package "c" (perhaps you forgot to load "c"?) at bareword.pl line 13.