#!/usr/bin/perl

## Turns local,1,2,3 column into separate columss.
##
##  usage: join123local < input > output
##
## Used for manually building Priority mail table from
## output of html2tab.


use Getopt::Std;

getopts('cd:j:');

my $delim = $opt_c ? '\s*,\s*' : "\t";
my $joiner = $opt_c ? ',' : "\t";

$delim = $opt_d if $opt_d;
$joiner = $opt_j if $opt_j;

my @zones = qw/local 1 2 3 4 5 6 7 8/;
print join $joiner, 'weight', @zones;
print "\n";

while(<>) {
	s/\s+$//;
	@f = split /$delim/o, $_;
	print join $joiner, $f[0], $f[1], $f[1], $f[1], @f[1..$#f];
	print "\n";
}
