Line | |
---|
1 | #!/usr/bin/perl |
---|
2 | # |
---|
3 | # Usage: udo-parser.pl [DATEINAME] |
---|
4 | # liest von Textdatei oder stdin eine Datei in Udos favorisiertem Format, |
---|
5 | # nach dem Zeilen etwa so aussehen: |
---|
6 | # "[hexadezimal] # [dezimal]" |
---|
7 | # Pro Zeile ein Byte. |
---|
8 | # Gibt auf STDOUT den Bytestrom aus. |
---|
9 | # |
---|
10 | # Geschrieben 30.03.2008 21:00 |
---|
11 | # |
---|
12 | |
---|
13 | my $handler = STDIN; |
---|
14 | open($handler, '<', $ARGV[0]) if(@ARGV > 0); |
---|
15 | |
---|
16 | my $line=0; |
---|
17 | my $hex,$dec; |
---|
18 | while(<$handler>) { |
---|
19 | $line++; |
---|
20 | unless(/([0-9a-fA-F]{2})\s*#\s*([0-9]{1,3})/) { |
---|
21 | print STDERR "Zeile $line: Formatfehler! Überspringe Zeile $line...\n"; |
---|
22 | next; |
---|
23 | } |
---|
24 | |
---|
25 | $hex=$1; $dec=$2; |
---|
26 | if(hex $hex ne $dec) { |
---|
27 | print STDERR "Zeile $line: Hex($hex)/Dez($dec)-Angabe stimmen nicht überein (hex entspricht ",hex $hex,").\n"; |
---|
28 | print STDERR "Zeile $line: Nutze Dezimal-Angabe fuer Streifen\n"; |
---|
29 | } |
---|
30 | |
---|
31 | print pack("C", $dec); |
---|
32 | # ja das wars schon ;) |
---|
33 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.