_END_OF_USAGE_
}
-# Copyright 2025 FUKUDA Satomi (https://satomichan.jp/tel2ma)
+# Copyright 2025 FUKUDA Satomi (https://satomichan.jp/about_tel2ma)
#
# Licensed under the Apache License, Version 2.0 (the “License”);
# you may not use this file except in compliance with the License.
foreach my $line (<DATA>) {
chomp $line;
- $line =~ s/#.?$//;
- $line =~ s/\s+?$//;
+ $line =~ s/#.*$//;
+ $line =~ s/\s+$//;
next unless $line;
- my( $pref, $ma, $city, $range, $area ) = split(/\s+/, $line);
+ my( $pref, $ma, $area_codes, $range, $munics ) = split(/\s+/, $line);
- my @cc = sort { length $b <=> length $a } split(/,/, $city);
- foreach my $c (@cc) {
+ my @ac = sort { length $b <=> length $a } split(/,/, $area_codes);
+ foreach my $ac (@ac) { #市外局番ごと
- next unless $tel =~ /^$c/;
+ next unless $tel =~ /^$ac/;
- foreach my $r ( split(/,/, $range) ) {
+ foreach my $r ( split(/,/, $range) ) { #ひと番号領域ごと
$r =~ s/(\d)~(\d)$/[$1-$2]/;
if( $tel =~ /^0$r/ ) {
- my $end = substr($tel, -4);
- my $sta = substr($tel, length $c, (6 - length $c));
- print "$c-$sta-$end ${ma}MA $area\n";
+ #市内局番
+ my $exch = substr($tel, length $ac, (6 - length $ac));
+ #加入者番号
+ my $subsc = substr($tel, -4);
+
+ print "$ac-$exch-$subsc ${ma}MA $munics\n";
exit;
}
- } #r
- } #c
+ } #ひと番号領域ごと
+ } #市外局番ごと
} #line
exit;