in reply to Re^2: AM Radio Station Finder
in thread AM Radio Station Finder

Rather than require the data to be local, why don't you make your perl script fetch the data from the web, real time? You could even have it cache the data locally, with expiration, etc.

We're building the house of the future together.

Replies are listed 'Best First'.
Re^4: AM Radio Station Finder
by davebaker (Pilgrim) on Dec 22, 2005 at 22:55 UTC
    Cool idea!

    The data file is many megs in size; it basically covers anything you might hear on the AM band at night, not just the U.S. and Canada. So it took about a minute for it to download to my local installation.

    I like the idea of downloading the current data, in order to have the most recent information... your link worked great!

    I was actually able to revise the script in only about 15 minutes' time... maybe I'm starting to know what I'm doing! Thanks for the opportunity to stretch my programming legs.

    Here are the only changes I needed to make:

    # old # use Fcntl qw( :flock ); # new use LWP::Simple; # old # open my $fh, '<', 'stations.dat' # or die "Trouble opening stations.dat; is it in same directory as + stations.exe? Stopped: $!"; # flock $fh, LOCK_SH # or die "Trouble getting file lock for stations.dat; is it in use + by another program? Stopped: $!"; # # while (my $line =~ <$fh>) { # new my $stations_data = get( 'http://www.fcc.gov/fcc-bin/amq?state=&call=& +arn=&city=&freq=530&fre2=1700&type=0&facid=&class=&list=4&dist=&dlat2 +=&mlat2=&slat2=&NS=N&dlon2=&mlon2=&slon2=&EW=W&size=9' ); my @data_lines = split /\n/, $stations_data; LINE: foreach my $line (@data_lines) { next LINE unless ($line =~ /\|/); # old (later in the script) # close $fh; # new (delete that line)

    ---

    THANKS again! Maybe I'll give a try at storing the data I've collected through LWP::Simple.

    Dave