Skip to content

Commit

Permalink
Added some something-doing iwlist scan parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Tadeusz Sośnierz committed Jul 17, 2010
0 parents commit d36f269
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions parser.pl
@@ -0,0 +1,26 @@
use strict;
use warnings;
use feature 'say';
use Data::Dumper;

my $iter = -1;
my @nws;

while(<>) {
s/^\s*//;
if (m/^Cell /) {
$nws[++$iter] = {};
($nws[$iter]->{addr}) = m/Address: (.+)$/;
}
($nws[$iter]->{channel}) = $1 if m/^Channel:(\d+)$/;
if (m/Quality=(\d+)\/(\d+)/) {
$nws[$iter]->{quality} = int($1 / $2 * 100 + .5);
}
($nws[$iter]->{encckey}) = $1 if m/^Encryption key:(.+)$/;
($nws[$iter]->{essid}) = $1 if m/^ESSID:"([^"]+)"$/;
($nws[$iter]->{wpaver}) = $1 if m/^IE: WPA Version (\d)$/;
}

@nws = reverse sort {$a->{quality} <=> $b->{quality}} @nws;

print Dumper @nws;

0 comments on commit d36f269

Please sign in to comment.