Du befindest dich hier: FSI Informatik » Informationen » linuxkurs » Aufgabensammlung » Mensaskript (Übersicht)
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.
Letzte ÜberarbeitungBeide Seiten, nächste Überarbeitung | |||
informationen:linuxkurs:aufgabensammlung:mensa [26.08.2016 06:27] – vorkurs => linuxkurs tomabrafix | informationen:linuxkurs:aufgabensammlung:mensa [18.10.2016 15:01] – rudis | ||
---|---|---|---|
Zeile 3: | Zeile 3: | ||
< | < | ||
- | #! / | + | # |
+ | use v5.12; | ||
use strict; | use strict; | ||
- | use integer; | + | use warnings; |
- | use Term:: | + | use utf8; |
- | use Date::Format; | + | use open qw( :std :locale |
- | my $time = time; | + | |
- | if ($#ARGV >= 0) { | + | |
- | $time += $ARGV[0] * 86400; | + | |
- | } | + | |
- | my $date = time2str(" | + | |
- | my @pars = split(/\n\s*\n/m, `w3m -dump http:// | + | use HTML:: |
+ | use WWW::Mechanize (); | ||
- | my @result = grep { /${date}/ } @pars; | ||
- | $, = " | + | my $URL = ' |
- | print @result; | ||
- | print " | ||
+ | sub get_food { | ||
+ | my ($html) = @_; | ||
+ | |||
+ | foreach my $line (split /\n/, $html) { | ||
+ | next unless $line =~ / | ||
+ | |||
+ | $line =~ m{< | ||
+ | say $1; | ||
+ | |||
+ | while ($line =~ m{(Essen \d+)</ | ||
+ | my $food = $1; | ||
+ | my $name = $2; | ||
+ | |||
+ | $name =~ s{< | ||
+ | $name =~ s{\s+}{ }g; | ||
+ | say " | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | my $mech = WWW:: | ||
+ | |||
+ | $mech-> | ||
+ | get_food($mech-> | ||
+ | |||
+ | for (my $i = 0; $i < 2; $i++) { | ||
+ | my $next = $mech-> | ||
+ | $mech-> | ||
+ | get_food($mech-> | ||
+ | } | ||
</ | </ | ||
- | Dieses // | + | Dieses // |
Sinnvollerweise sollte das Script als '' | Sinnvollerweise sollte das Script als '' |