in reply to More than one way to skin an architecture

I assume that you have the following: In order to display the data, I assume that you're going to do something like this, Foreach Ship: IMHO the most simple thing to do would be: Once you've plotted today's data, all you need to do is go through all of today's data (foreach ship name) and: Then, whenever you start the program up, you'll only have to: Now, for the hash part. The hash I have in mind would be like:
# today's data -- your starting point my %SHIPS = ( SHIP1 => [ {datetime => '20080318-0730', latitude => '10.33', longitude => '- +05.45'}, ], # other ships );
You can then save that via Data::Dumper:
use Data::Dumper; print Data::Dumper::Dumper([\%SHIPS],[*SHIPS]); # save to file, don't +print
This specific invocation of Data::Dumper::Dumper will give you exactly what you have in the hash.
The cool thing is that at the subsequent start of the program all you have to do is to "do" the file, and Perl will get the contents of the %SHIPS hash you had at the previous run:
my %SHIPS; do 'dumped_file';
As above, all you'd then have to do is display the data, merge it with the historical, and save again.

The "merge" (assuming you are reading through a CSV on <>) is something like:
while (<$CSV>) { chomp; # assume csv is SHIP1,DATETIME,LATITUDE,LONGITUDE. # modify accordingly.. my ($shipname, $datetime, $latitude, $longitude) = split(/\,/$_); my %today_details = (datetime => $datetime, latitude => $latitude, l +ongitude => $longitude); # this is what will get pushed on the arrayr +ef my @arr = @{$SHIPS{$shipname} || []}; # get curr contents push (@arr, \%today_details); # push today's data $SHIPS{$shipname} = \@arr; # push back } # that's you done with the merge
Really, even if it does get VERY long... it's not like your PC can't handle a 10MB file after some time..
Or maybe you'd want to implement a "dump older than one month details".. you'll simply go through the hash, then through the arrayref, and discard all the entries which are older than a specified time.. Exercise left to the reader ;)
Hope this has helped :)

Replies are listed 'Best First'.
Re^2: More than one way to skin an architecture
by mcoblentz (Scribe) on Mar 19, 2008 at 04:44 UTC
    I think that this is the general direction I will try first. One of the things that occurred to me during this conversation is that the most likely historical query would be to pick a ship and plot its track over time. I don't think I would ever query by a geographical location (lat/long box or circle search) ever. That doesn't make any sense to me (at least right now. If I have to do it later, I could always just dump the file into a DB and query it that way.

    I like the idea of being able to trim the historical data by ship/date, because I don't have to trim all ships to the same period.