Thread HTML mit Perl regex parsen
(9 answers)
Opened by Lauvia at 2013-09-06 12:50
Hallo Linuxer,
hatte die Glocken zu früh läuten lassen, bin bei der letzten Prüfung hängen geblieben. hier mein Code: Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 while (my $line = <$read_handle>) { my $Inca_Name; my $Inca_Vchk; my $Inca_Comment; #-------------------------------------------------------------------- # Variable check bloc #-------------------------------------------------------------------- if ($line =~ /class\=/ and $line =~ /CAN signal/) { #my %VarCheck; #my $Inca_Name; #my $Inca_Vchk; #my $Inca_Comment; #-----collect Signal Informations----------------------------------- ($Inca_Vchk, $Inca_Name, $Inca_Comment)= $line =~ /^<[A-Z]+\s+[a-z]+\=\'([a-z]+)\'><[A-Z]+>[^0-9]+<\/[A-Z]+><[A-Z]+>\'([a_zA-Z0-9_]+)\'\s+([^0-9]*?)<[^0-9]+/; #$VarCheck{'INCA_NAME'} = $Inca_Name; #$VarCheck{'INCA_VCHK'} = $Inca_Vchk; #$VarCheck{'INCA_COMMENT'} = $Inca_Comment; #$VarCheck{'SIGNAL'} = \@Signals; push(@Sig_Incadata, $Inca_Vchk, $Inca_Name, $Inca_Comment); print "Variable Check:\n\n$Inca_Vchk $Inca_Name $Inca_Comment\n\n"; # 1. Prüfstelle } #-------------------------------------------------------------------- # END Variable check bloc #-------------------------------------------------------------------- #-------------------------------------------------------------------- # Bus resolution check bloc #-------------------------------------------------------------------- if ($line =~ /class\=/ and $line =~ /ECU internal variable/) { my $Int_Vchk; my $Int_Name; my $Int_Comment; #-----collect Signal Informations----------------------------------- my $regexp = qr { class='([^']+)'.*?<TD>'([^']+)'\s*([^<]+)</TD> }x; # ENDE Regexp ($Int_Vchk, $Int_Name, $Int_Comment) = $line =~ $regexp; push(@Sig_Intdata, $Int_Vchk, $Int_Name, $Int_Comment); print "Resolution Check:\n\n$Int_Vchk $Int_Name $Int_Comment \n\n"; # 2. Prüfstelle } #-------------------------------------------------------------------- # END Bus resolution check bloc #-------------------------------------------------------------------- #-------------------------------------------------------------------- # Signal conversion check bloc #-------------------------------------------------------------------- if ($line =~ /class='/ and ($line !~ /ECU internal resolution/)and ($line =~ /$Sig_Incadata[1]/) and ($line =~ /\d+/)) { my $Sig_ConChk; my $Sig_ConCom; my $Bus_Value; my $Ecu_Value; my $deviation; #-----collect Signal Informations----------------------------------- my $regexp = qr { class='([^']+)'.*?<TD>(\d+)[^']+<TD>(\d+)<\/TD><TD>(\d+)<\/TD><TD>([^']+)</TD> }x; # ENDE Regexp (Problem liegt sicherlich hier) ($Sig_ConChk, $Bus_Value, $Ecu_Value, $deviation, $Sig_ConCom)= $line =~ $regexp; push(@table, $Sig_ConChk, $Bus_Value, $Ecu_Value, $deviation, $Sig_ConCom); print "Test:\n\n@Sig_Incadata\n@Sig_Intdata"; print "$table[1]\n"; # 3. Prüfstelle } #-------------------------------------------------------------------- # END Signal conversion check bloc #-------------------------------------------------------------------- } <>; Ohne Signal Conversion Bloc funktioniert das Skript, deswegen bin ich mir fast sicher der Ausdruck in der Zeile 74 nicht stimmt. Wie hättest du ihn geschrieben? PS: html Muster habe ich hochgeladen! Anhänge |