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 :)

In reply to Re: More than one way to skin an architecture by okram
in thread More than one way to skin an architecture by mcoblentz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.