sub checkLogin { my $loginName = shift; # Do not clobber open FH file handles local *FH; my $file = $SETTINGS{userfile}; open FH, $file or die qq(Cannot open "$file": $!); flock FH, LOCK_EX if $^O ne 'MSWin32'; while ( <FH> ) { my( $user, $password ) = ( split /\t/, $_ )[1, 2]; if ( $user =~ m/^$loginName$/) { if ( $password =~ m/^$password$/) { return 'true'; } } } close FH; return ''; }
Example 3: Eliminating a flag variable.