Universität Ulm, Fakultät für Mathematik und Wirtschaftswissenschaften, SAI

Lösung zu Blatt 1 --- Software Engineering Praxis (WS 2000)

1. Who wants to live forever

#!/usr/local/bin/perl -w

use strict;

open(FILE, "<dav94t325m") || die "Cannot open file\n";
my $start = $ARGV[0] || 0;
foreach (0 .. $start) { <FILE> || die "unexpected end of file\n"; };
my ($num, $sum) = (0, 0);
my $l = undef;
while (<FILE>) {
   $num = (split /:/)[2];
   $sum += $num;
   $l = $num unless defined $l;
}
close(FILE);
print $sum / $l - 0.5, "\n";

Universität Fakultät SAI

Ingo Melzer, 10. November 2000