Text processing/Max licenses in use: Difference between revisions

Content added Content deleted
m (Reverted edits by Dijkstra (talk) to last revision by GetBreak)
m (→‎{{header|Perl 6}}: Add some error trapping as recommended by Dijkstra. No change to output)
Line 1,750: Line 1,750:


=={{header|Perl 6}}==
=={{header|Perl 6}}==
Add some error trapping as recommended by [[Dijkstra]]. Not particularly necessary for this specific example but it doesn't hurt to be proactive.


Redirecting the mlijobs.txt file to STDIN:
Redirecting the mlijobs.txt file to STDIN:
<lang perl6>my %licenses;
<lang perl6>my %licenses;
Line 1,755: Line 1,758:
%licenses<count max> = 0,0;
%licenses<count max> = 0,0;


for $*IN.lines -> $line {
for $*IN.lines -> $line {
my ( $license, $date_time );
my ( $license, $date_time );
( *, $license, *, $date_time ) = split /\s+/, $line;
( *, $license, *, $date_time ) = split /\s+/, $line;
Line 1,768: Line 1,771:
}
}
}
}
else {
elsif $license eq 'IN' {
if %licenses<count> == %licenses<max> {
if %licenses<count> == %licenses<max> {
%licenses<times>[*-1] ~= " through " ~ $date_time;
%licenses<times>[*-1] ~= " through " ~ $date_time;
}
}
%licenses<count>--;
%licenses<count>--;
}
else {
# Not a licence OUT or IN event, do nothing
}
}
};
};