File: kruft2codes.pl

package info (click to toggle)
liblocale-us-perl 3.04-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 108 kB
  • sloc: perl: 110; makefile: 7
file content (28 lines) | stat: -rw-r--r-- 396 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/perl

#system 'lynx -dump http://www.usps.gov/ncsc/lookups/usps_abbreviations.htm > kruft.txt';
open P, 'kruft.txt';

while (<P>) {
    if (/\w/) 
    {

	$_ =~ s/^\s+//;
	$_ =~ s/\s+$//;

	if (++$line_count % 2) 
	{
	    $current_state=$_;
	} 
	else 
	{
	    $code{$current_state}=$_;
	}
    }    
}

open C, '>codes.dat';
foreach (sort keys %code) {
    print C "$code{$_}:$_\n";
}