#!/usr/bin/perl # 街路 parser... # Author: Dan Jacobson https://www.jidanni.org/ # Copyright: https://www.gnu.org/licenses/gpl.htm # Created: 2024-04-15T01:47:45+0000 # Last-Updated: 2024-04-17T06:06:40+0000 # Update #: 50 # 門牌條例 says use road width to determine St. vs. Rd... ## Input: lines like: ## 7500 路2646號 ## 7600街 2543號 ## 2600路 7658號 ## 2600路7551號 ## Output: lines like: ## 2646 7490 2646 ## 2543 7610 2543 ## 2590 7658 7658 ## 2610 7551 7551 ## which are coordinates of where to put the house on the map, set ## back from the road in the correct directrion. my $usage = "Give lines of number <路|街> number 號. Spaces optional."; my @setback = ##meters. Want to use less a percent of the 100 numbers ## of the longer EW oriented block direction ( 8, 10 ); ## What if users give us 2040-A, 2040A? while (<>) { chomp; /^\s*(\d+)\s*(?:路|街)\s*(\d+)\s*號\s*$/ or die "$usage"; my ( $road, $house ) = @{^CAPTURE}; ## We will use "AI" to check the road number to figure out if it is NS or EW: my $wesn = $road >= $ENV{WeSnLimit}; $road += $setback[$wesn] * ( $house % 2 ? 1 : -1 ); my @F = ( $road, $house ); printf "%s %s %s$/", @F[ $wesn, !$wesn ], $F[1]; }