Mercurial > hg > lukkari
comparison parsedata.pl @ 55:656b2a22b945
Merged.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 23 Oct 2012 19:01:11 +0300 |
parents | 0d574e3248b5 1c5174dcd92a |
children | 93c87f42c803 |
comparison
equal
deleted
inserted
replaced
54:0d574e3248b5 | 55:656b2a22b945 |
---|---|
272 ### Parse through the HTML document node tree to find the data we need | 272 ### Parse through the HTML document node tree to find the data we need |
273 my $cid = 0; | 273 my $cid = 0; |
274 my $q = $$node{"nodes"}; | 274 my $q = $$node{"nodes"}; |
275 my $hourDefs = {}; | 275 my $hourDefs = {}; |
276 my $hourTable = {}; | 276 my $hourTable = {}; |
277 my $maxDays = 6; | 277 my $maxDays = 0; |
278 my $maxHours = 0; | 278 my $maxHours = 0; |
279 | 279 |
280 # Skip zero position this way (can't use foreach here) | 280 # Skip zero position this way (can't use foreach here) |
281 for (my $i = 1; $i < scalar(@{$q}); $i++) { | 281 for (my $i = 1; $i < scalar(@{$q}); $i++) { |
282 my $d = $$q[$i]{"nodes"}; | 282 my $d = $$q[$i]{"nodes"}; |
310 } else { | 310 } else { |
311 $tid = 0; | 311 $tid = 0; |
312 } | 312 } |
313 | 313 |
314 my $cday = 0; | 314 my $cday = 0; |
315 for (my $x = 0; $x < $maxDays; $x++) { | 315 for (my $x = 0; $x < 7; $x++) { |
316 if (!defined($$hourTable{$maxHours}{$x})) { | 316 if (!defined($$hourTable{$maxHours}{$x})) { |
317 $cday = $x; | 317 $cday = $x; |
318 $maxDays = $x if ($x > $maxDays); | |
318 last; | 319 last; |
319 } | 320 } |
320 } | 321 } |
321 for (my $t = 0; $t < $chours; $t++) { | 322 for (my $t = 0; $t < $chours; $t++) { |
322 $$hourTable{$maxHours + $t}{$cday} = $tid; | 323 $$hourTable{$maxHours + $t}{$cday} = $tid; |
340 for (my $x = 0; $x < $maxDays && $flag; $x++) { | 341 for (my $x = 0; $x < $maxDays && $flag; $x++) { |
341 $flag = 0 if (defined($$hourTable{$y}{$x}) && $$hourTable{$y}{$x} != 0); | 342 $flag = 0 if (defined($$hourTable{$y}{$x}) && $$hourTable{$y}{$x} != 0); |
342 } | 343 } |
343 $maxHours-- if ($flag); | 344 $maxHours-- if ($flag); |
344 } | 345 } |
345 | |
346 $flag = 1; | |
347 for (my $x = $maxDays - 1; $x >= 0 && $flag; $x--) { | |
348 for (my $y = 0; $y < $maxHours && $flag; $y++) { | |
349 $flag = 0 if (defined($$hourTable{$y}{$x}) && $$hourTable{$y}{$x} != 0); | |
350 } | |
351 $maxDays-- if ($flag); | |
352 } | |
353 | |
354 | 346 |
355 ### Open output file, if specified | 347 ### Open output file, if specified |
356 if (defined($opt_outfile)) { | 348 if (defined($opt_outfile)) { |
357 open(STDOUT, '>', $opt_outfile) or die("Could not open output file '$opt_outfile'.\n"); | 349 open(STDOUT, '>', $opt_outfile) or die("Could not open output file '$opt_outfile'.\n"); |
358 } | 350 } |