Text processing/Max licenses in use: Difference between revisions

(add Gema section)
Line 784:
2008/10/03_08:39:34
2008/10/03_08:40:40</pre>
=={{header|Lua}}==
<lang lua>
filename = "mlijobs.txt"
io.input( filename )
 
max_out, n_out = 0, 0
occurr_dates = {}
 
while true do
line = io.read( "*line" )
if line == nil then break end
 
if string.find( line, "OUT" ) ~= nil then
n_out = n_out + 1
if n_out > max_out then
max_out = n_out
occurr_dates = {}
occurr_dates[#occurr_dates+1] = string.match( line, "@ ([%d+%p]+)" )
elseif n_out == max_out then
occurr_dates[#occurr_dates+1] = string.match( line, "@ ([%d+%p]+)" )
end
else
n_out = n_out - 1
end
end
 
print( "Maximum licenses in use:", max_out )
print( "Occurrences:" )
for i = 1, #occurr_dates do
print( "", occurr_dates[i] )
end</lang>
Output:
<pre>Maximum licenses in use: 99
Occurrences:
2008/10/03_08:39:34
2008/10/03_08:40:40</pre>
 
=={{header|M4}}==
Anonymous user