Thread Benötige wieder hilfe bei RegEx
(5 answers)
Opened by
jogi
at 2007-07-28 15:45
User since 2007-07-25
55
Artikel
BenutzerIn
Hi!
Ich möchte aus einem File, dessen Inhalt wie unten aussieht, die Zeilen router und bandwidth extrahieren. Das ist nicht das Problem. Das Problem ist, dass ich nicht weiß wie ich die übrigen Zeilen überspringe. Ganz unten mein Versuch, wäre nett wenn mir jemand den Fehler aufzeigen könnte. Danke.
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
router nefarion 87.11.203.227 9001 0 0 platform Tor 0.1.2.14 on Linux i586 published 2007-07-26 17:07:49 opt fingerprint F1A3 2578 821B 364A A83A DE00 434B 415A 4C2F 627A uptime 537449 bandwidth 49152 6291456 45857 onion-key -----BEGIN RSA PUBLIC KEY----- MIGJAoGBAKtulT/DFxMpO7ZNn8dLUyGh6iGR5m0VQhoyNSHuHOkR2KE9fpvkLeE/ 8jGYndrrK4Gw4r+YhvD65gVTmKYMXEyrfVtLC66h66hICWoG2ZExq3SDPCW8YAVE bcmo8oueFOJ8PnZYgogkwzc6aRS+8MV4zMuHUi3M1zwX/ROK3dqRAgMBAAE= -----END RSA PUBLIC KEY----- signing-key -----BEGIN RSA PUBLIC KEY----- MIGJAoGBALdErdmmtayN7gyLXv0DBV/wXT605LSO8zyR+jkSc2tBMurNmuqI0lM+ wDJ3feWoOqQOBeiOZZ5p2NTcHacIEoiBpoBNmG5RtGomaCJSKtad3ffD2fbTUxsf m0G14G9ClPUu5t5Et3Enq6ZUbLbBn+JbS5Hnx2WP6ovrCiKfYJ2/AgMBAAE= -----END RSA PUBLIC KEY----- family geonosis pboxlevel2 pboxlevel3 pboxlevel4 opt write-history 2007-07-26 17:06:37 (900 s) 14320640,13688832,16859136,29580288,25198592,28904448,14724096,13925376,13262848,16100352,
13638656,6964224,3017728,1100800,2880512,7872512,9539584,9414656,15409152,4396032,1184768,
1048576,4308992,715776,448512,7297024,914432,2723840,2770944,2479104,5811200,7079936,38574
08,8426496,10225664,10241024,12942336,5775360,10285056,9140224,6825984,3042304,16439296,20
579328,6725632,6609920,4644864,9314304,20026368,4507648,10474496,12678144,10508288,1575526
4,13091840,8236032,4442112,5550080,7455744,25936896,28393472,26279936,28430336,23921664,78
06976,4611072,5912576,5428224,7476224,9204736,6823936,12043264,15856640,11703296,9952256,1
3234176,12707840,9490432,9966592,8666112,15092736,15429632,15140864,31276032,30113792,3124
5312,31264768,30256128,30390272,30875648,30838784,28485632,14939136,20109312,27210752,2124
9024 opt read-history 2007-07-26 17:06:37 (900 s) 14376960,13846528,17029120,30103552,25216000,29231104,14795776,14143488,13300736,16371712,
13693952,7074816,3025920,1105920,2989056,7917568,9668608,9433088,15450112,4504576,1186816,
1147904,4319232,828416,456704,7430144,922624,2840576,2793472,2608128,5833728,7225344,38850
56,8449024,10430464,10269696,13073408,5820416,10445824,9319424,6872064,3058688,17531904,20
015104,6721536,7081984,4654080,9739264,20051968,4626432,10509312,12833792,10768384,1579212
8,13165568,8582144,4475904,5685248,7493632,26348544,28743680,26527744,28738560,24382464,80
03584,4627456,6052864,5453824,7701504,9243648,6970368,12445696,16267264,11726848,10089472,
13473792,12743680,9628672,10108928,8583168,15285248,15717376,15580160,31503360,30382080,31
796224,31130624,30599168,30806016,31851520,30905344,28558336,15008768,20229120,27380736,21
647360 contact Pbox admin <pbox-admin@winstonsmith.info> reject *:* router-signature -----BEGIN SIGNATURE----- Kxo8sxp9rRrUJIciWc7728nuKTvJ+ZaiwUeYWwIPXgJSSV8/UHG7qWARcGo9JBB9 Y5vz1YNaMnZWV7j/gbVwu4XG6QR+qvsnCFMpspHVWIj3J+v0I9438NXbyQ4/twiy o9TWMcJ606F3MG/FFO1ulPFrKbI+SS/+I8/20KjG/Cg= -----END SIGNATURE----- router Celltel 85.214.18.16 9001 0 0
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
#!/usr/bin/perl -w
use strict;
my $cached_routers = "C:\\Dokumente und Einstellungen\\ich\\Anwendungsdaten\\tor\\cached-routers";
my ($nickname, $ipaddress, $ORPort, $SOCKSPort, $DirPort, $avg_bandwidth, $burst_bandwidth, $observed_bandwith);
open (FILE, "<$cached_routers") or die $!; while (my $line = <FILE>) {
if ($line !~ /router/) { next }; if ($line !~ /bandwidth/){ next };
if ( $line =~ /router\s(\w+)\s(\d+\.\d+\.\d+\.\d+)\s(\d+)\s(\d+)\s(\d+)/) { $nickname = $1; $ipaddress = $2; $ORPort = $3; $SOCKSPort = $4; $DirPort = $5; #$NL = $6; #print "$nickname $ipaddress $ORPort $SOCKSPort $DirPort\n"; } if ( $line =~ /bandwidth\s(\d+)\s(\d+)\s(\d+)/) { $avg_bandwidth = $1; $burst_bandwidth = $2; $observed_bandwith = $3; }
open (FILE2, ">>router.txt") or die $!; print FILE2 "$nickname $ipaddress $avg_bandwidth\n"; close (FILE2); }
\n\n
<!--EDIT|jogi|1185623179-->
View full thread Benötige wieder hilfe bei RegEx
|