use strict; use warnings; my %passwords = ( moritz => 'secret', ); while() { chomp; if (exists $passwords{$_}){ print "Password from $_ is '$passwords{$_}'\n"; } else { print "No password for $_, sorry\n"; } } #### $ perl script.pl moritz Password from moritz is 'secret' someone else No password for someone else, sorry