~fredg/rezo

51f8d37a9c2a22932ddeeb3a84afdeb6acb703f0 — alienus 7 years ago a5813c0
sort seems to be useless for array now in 5.20.1 in 5.7 && desc is sometimes not defined
1 files changed, 11 insertions(+), 4 deletions(-)

M rezo
M rezo => rezo +11 -4
@@ 11,7 11,7 @@ use strict;
use warnings;
use 5.010;
use Getopt::Long;
#use Data::Dumper;
use Data::Dumper;

# check root
( $< == 0 ) or die "Sorry, but only root can play with networks, aborting...\n";


@@ 20,7 20,7 @@ use Getopt::Long;
my $VERSION = '0.0';

# wireless interface & ifconfig path
my $nwif = 'iwn0';
my $nwif = 'wpi0';
my $ifconfig = '/sbin/ifconfig';

# help


@@ 77,7 77,7 @@ sub scan {
    }
    close SCANR;
    # sort by dB
    @netlist = sort { $b->[6] cmp $a->[6] } @netlist;
    #@netlist = sort { $b->[6] cmp $a->[6] } @netlist;
    return @netlist;
}
scan();


@@ 85,10 85,17 @@ scan();

my $inet = @netlist;
sub test {
    say "-" x72;
    say "Nb\tdB\tSSID";
    say "-" x72;
    for my $i (0 .. ($inet - 1) ) {
        my $nb = $i +1;
        $netlist[$i][1] =~ s/~~~/ /g;
        say "$nb:\t$netlist[$i][6]:\t$netlist[$i][1]";
        $netlist[$i][8] = '-o-o-' unless defined($netlist[$i][8]);
#my ($nwid,$SSID,$chan,$channb,$bssid,$bssidn,$db,$agn,$desc);        
        say "$nb:\t$netlist[$i][6]\t$netlist[$i][1]\t$netlist[$i][8]";
    }
}
test();

#say Dumper @netlist;