comparison parsedata.pl @ 181:9c3100ab29cc

Cosmetics.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 08 Sep 2015 10:48:48 +0300
parents eaac0a84a7d2
children 9f7eb4db99b4
comparison
equal deleted inserted replaced
180:b4a07ea2d739 181:9c3100ab29cc
392 392
393 ### 393 ###
394 ### Main program 394 ### Main program
395 ### 395 ###
396 396
397 while (defined(my $arg = shift)) { 397 while (defined(my $arg = shift))
398 if (substr($arg, 0, 1) eq "-") { 398 {
399 if ($arg =~ /^-($modes)$/o) { 399 if (substr($arg, 0, 1) eq "-")
400 {
401 if ($arg =~ /^-($modes)$/o)
402 {
400 $opt_mode = $1; 403 $opt_mode = $1;
401 } 404 }
402 elsif ($arg eq "-dump") { 405 elsif ($arg eq "-dump")
406 {
403 $opt_dump = 1; 407 $opt_dump = 1;
404 } 408 }
405 elsif ($arg eq "-o") { 409 elsif ($arg eq "-o")
410 {
406 $opt_outfile = shift or die("Output filename option -o requires an argument.\n"); 411 $opt_outfile = shift or die("Output filename option -o requires an argument.\n");
407 } else { 412 }
413 else
414 {
408 die("Invalid option '$arg'.\n"); 415 die("Invalid option '$arg'.\n");
409 } 416 }
410 } else { 417 }
418 else
419 {
411 $opt_filename = $arg; 420 $opt_filename = $arg;
412 } 421 }
413 } 422 }
414 423
415 die("Usage: $0 [options] <filename> 424 die("Usage: $0 [options] <filename>
447 exit; 456 exit;
448 } 457 }
449 458
450 my %class = (); 459 my %class = ();
451 my $body = fnode($otree, "body"); 460 my $body = fnode($otree, "body");
452 if (defined($body) && defined($$body{"nodes"})) { 461 if (defined($body) && defined($$body{"nodes"}))
453 foreach my $n (@{$$body{"nodes"}}) { 462 {
454 if ($$n{"name"} eq "text") { 463 foreach my $n (@{$$body{"nodes"}})
464 {
465 if ($$n{"name"} eq "text")
466 {
455 push(@{$class{"info"}}, $$n{"text"}); 467 push(@{$class{"info"}}, $$n{"text"});
456 } 468 }
457 elsif ($$n{"name"} eq "b") { 469 elsif ($$n{"name"} eq "b")
470 {
458 push(@{$class{"data"}}, $n); 471 push(@{$class{"data"}}, $n);
459 } 472 }
460 } 473 }
461 } 474 }
462 475