Skip to content

Commit

Permalink
Delete useless $_ =~ from regrex parser in netstat.
Browse files Browse the repository at this point in the history
  • Loading branch information
bluhm committed Aug 29, 2024
1 parent 3dac12a commit 7d2e07a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Netstat.pm
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,18 @@ sub parse {
or die "Open '$fname' for reading failed: $!";

while(<$fh>) {
if ($_ =~ /^(\w+):$/) {
if (/^(\w+):$/) {
$l1 = canonicalize_key $1;
$netstat{$l1} = {}
} elsif ($_ =~ /^ ([^: ]+): (\d+)$/) {
} elsif (/^ ([^: ]+): (\d+)$/) {
my $k = canonicalize_key($1);
if (ref($netstat{$l1}{$l2}{$l3}) ne "HASH") {
my $total = $netstat{$l1}{$l2}{$l3};
$netstat{$l1}{$l2}{$l3} = {};
$netstat{$l1}{$l2}{$l3}{total} = $total;
}
$netstat{$l1}{$l2}{$l3}{$k} = $2;
} elsif ($_ =~ /^ (\d+) (.+)$/) {
} elsif (/^ (\d+) (.+)$/) {
$l3 = canonicalize_key $2;
my $v = $1;
if (ref($netstat{$l1}{$l2}) ne "HASH") {
Expand All @@ -98,10 +98,10 @@ sub parse {
$netstat{$l1}{$l2}{$k2} = $v2;
}
$netstat{$l1}{$l2}{$l3} = $v;
} elsif ($_ =~ /^ ([^:]+): (\d+)$/) {
} elsif (/^ ([^:]+): (\d+)$/) {
$l3 = canonicalize_key $1;
$netstat{$l1}{$l2}{$l3} = $2;
} elsif ($_ =~ /^ (\d+) (.+)$/) {
} elsif (/^ (\d+) (.+)$/) {
my $v = $1;
$l2 = canonicalize_key $2;
if ($l2 =~ /\((.+)\)/ && $1 =~ /\d/) {
Expand All @@ -113,7 +113,7 @@ sub parse {
$netstat{$l1}{$k2} = $v2;
}
$netstat{$l1}{$l2} = $v;
} elsif ($_ =~ /^ ([^:]+):?$/) {
} elsif (/^ ([^:]+):?$/) {
$l2 = canonicalize_key $1;
$netstat{$l1}{$l2} = {};
} else {
Expand Down

0 comments on commit 7d2e07a

Please sign in to comment.