*NAME_MAP
*1 ab
*2 abc
*3 abcd
*4 def
*5 ghi
*6 klm
*7 mno
*8 kji
*9 ips
*10 dlm
*PORTS
*D_NET *2 25
*D_NET *3 16
*D_NET *5 8
*D_NET *9 3
####
#!/usr/bin/perl
#use strict;
use warnings;
open(IHF, "<", "top.spef");
while( ) {
my @keys;
my ($n, $k1);
my %nets;
my @net;
my $item;
next if (/^\n/);
s/\*//g;
s/^\s//g;
s/\//:/g;
### Here we store the lines between the lines
### NAME_MAP and PORT into a hash called %mapping"
### and print the key,value pairs
if (/NAME_MAP/ .. /PORTS/) {
next if (/NAME_MAP/);
next if (/PORTS/);
%mapping = split;
@keys = sort keys %mapping;
foreach $k1 (sort keys %mapping) {
print "$k1 = $mapping{$k1}\n";
}
}
if (/D_NET/) {
my @anet = split;
%nets = ($anet[1] , $anet[0]);
for $n (sort keys %nets) {
print "$mapping{$n}\n";
}
}
}
####
Use of uninitialized value in concatenation (.) or string at ./mapping.pl line 39, line 23
####
if (/D_NET/) {
my @anet = split;
%nets = ($anet[1] , $anet[0]);
for $n (sort keys %nets) {
print "$mapping{$n}\n";
}
}