my %opt; $opt{'M'} = \*MF; # You should use a reference here. while (readline($opt{'M'})) { print "loop one...\n"; }