[erlang-questions] Basic Erlang case question

Alexander Lamb alexander.lamb@REDACTED
Thu Jul 10 10:41:29 CEST 2008

Hello List,

Here is a very simple code to search if a supplied password is correct  
or not:

				F1 = fun() -> mnesia:match_object(systems,  
#system_info{full_attribute = {System_Name,admin_password}, _ = '_'},  
read) end,
				case Password of
					[] -> MD5_Password = [];
					_Any -> MD5_Password = erlang:md5(Password)
				case mnesia:transaction(F1) of
					{atomic, []} 								  -> {error, unknown_system};
					{atomic, [#system_info{data = MD5_Password}]} -> {ok, password};
					{atomic, _}									  -> {error, bad_password};
					{aborted, Reason}							  -> {error, Reason}

Basically, if supplied Password is empty, the MD5_Password must be  
empty. If not, I encrypt the Password to compare it with stored version.

My problem is that it compiles with a warning:

./cs_systems.erl:173: Warning: variable 'MD5_Password' exported from  
'case' (line 167)

Why? Obviously I am trying to match the password in the record I found  
with the password I supply.



More information about the erlang-questions mailing list