http://www.perlmonks.org?node_id=277693


in reply to In-place file filtering

Variation on the theme:

perl -MRegexp::Common=zip -i.bak -n -a -e 'print if m/\t$RE{zip}{US}$/ +' *.dat

Replies are listed 'Best First'.
Re: Re: In-place file filtering
by princepawn (Parson) on Jul 24, 2003 at 22:11 UTC
    from the docs of Regexp::Common::zip
    US zip codes consist of 5 digits, with an optional 4 digit extension

    But this allows zip codes which are not currently valid.

    Carter's compass: I know I'm on the right track when by deleting something, I'm adding functionality

      Fair point. Might be worth dropping a bug-report/patch to Abigail-II.

      Where do you get the info on which US codes are valid/invalid?

        To actually get the list of zip codes costs money, either from the USPS or other sources. However, by repeatedly typing in zip codes into the zip code locator as USPS.com I found out the valid upper and lower bounds.

        Carter's compass: I know I'm on the right track when by deleting something, I'm adding functionality

        Your friendly snail-mail corp will sell you same (sorta' -- they'll sell list of valid zips, from which one can deduce the 5 digit #s which are NOT valid.) But bigbuck$$$$.