File: parse_pf.pl

package info (click to toggle)
fwknop 1.9.12-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,696 kB
  • ctags: 604
  • sloc: perl: 14,617; ansic: 1,258; sh: 462; makefile: 88
file content (33 lines) | stat: -rwxr-xr-x 642 bytes parent folder | download
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
#!/usr/bin/perl -w

use strict;

open F, "< pf.os" or die;
my @lines = <F>;
close F;

#16384:64:0:60:M512,N,W%2,N,N,T:         AIX:4.3:3:AIX 4.3.3-5.2
#S3:64:1:60:M*,S,T,N,W0:         Linux:2.4:18-21:Linux 2.4.18 and newer

my %os;

for my $line (@lines) {
    next unless $line =~ /\S/;
    next if $line =~ /^\s*#/;
    chomp $line;

#    if ($line =~ /^\s*(\S+?:\S+?:\S+?:\S+?):\S+\s+(.*)/) {
    if ($line =~ /^\s*(\S+?:\S+?:\S+?:\S+?:\S+:)\s+(.*)/) {
        $os{$1}{$2} = '';
    }
}

for my $fp (sort keys %os) {
    print $fp, "\n";
    for my $os (sort keys %{$os{$fp}}) {
        print "    $os\n";
    }
    print "\n";
}

exit 0;