projects
/
tel2ma
/
.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
df3f161
)
js版に合わせて変数名変更, コメント追加. コメント(#)読み飛ばし部修正.
master
author
satomichan
<git-kitte.20250824@...>
Thu, 27 Nov 2025 03:44:11 +0000
(12:44 +0900)
committer
satomichan
<git-kitte.20250824@...>
Thu, 27 Nov 2025 03:44:11 +0000
(12:44 +0900)
tel2ma.pl
patch
|
blob
|
history
diff --git
a/tel2ma.pl
b/tel2ma.pl
index 83462e52954a352ba6cc89a9bd54fb4b179b38fd..a33a0e16221a4800f55f698d47afed43ce6a01c0 100755
(executable)
--- a/
tel2ma.pl
+++ b/
tel2ma.pl
@@
-12,7
+12,7
@@
ex) $ ./tel2ma.pl 033xxx-yyyy
_END_OF_USAGE_
}
_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.
#
# Licensed under the Apache License, Version 2.0 (the “License”);
# you may not use this file except in compliance with the License.
@@
-63,29
+63,32
@@
usage(), exit unless $tel =~ /^0.{9}$/;
foreach my $line (<DATA>) {
chomp $line;
foreach my $line (<DATA>) {
chomp $line;
- $line =~ s/#.
?
$//;
- $line =~ s/\s+
?
$//;
+ $line =~ s/#.
*
$//;
+ $line =~ s/\s+$//;
next unless $line;
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 =~ /^$
a
c/;
- foreach my $r ( split(/,/, $range) ) {
+ foreach my $r ( split(/,/, $range) ) {
#ひと番号領域ごと
$r =~ s/(\d)~(\d)$/[$1-$2]/;
if( $tel =~ /^0$r/ ) {
$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;
}
exit;
}
- } #
r
- } #
c
+ } #
ひと番号領域ごと
+ } #
市外局番ごと
} #line
exit;
} #line
exit;