On Wed, May 28, 2003 at 10:07:39PM -0400, Dale Lancaster wrote:
> For the perl hash, I would key the hash on the combo of planet and date,
> something like:
> 
> my %Planets = (
> 
>         jupiter    => {
>                                 "1900-01-01"    => ( "5h 39m 18s", "+22o
> 4.0'", 28.922, -15,128, -164.799, "set"),
>                                 "1900-01-02"    => ( "5h 39m 18s", "+22o
> 4.0'", 28.922, -15,128, -164.799, "set"),
>          },
> 
>         neptune    => {
>                                 "1900-01-01"    => ( "5h 39m 18s", "+22o
> 4.0'", 28.922, -15,128, -164.799, "set"),
>                                 "1900-01-02"    => ( "5h 39m 18s", "+22o
> 4.0'", 28.922, -15,128, -164.799, "set"),
>         },
> ) ;

my $Planets = {
        jupiter    => {
            1900 => {
              01 => {
                01 => 1, # Record number in a file
                02 => 2,
                    }.
              02 => { ...},
....

This would not require the entire dataset to be stored in memory but rather an offset 
to a file possition which could be randomly accessed.

However If I ever heard of a case for use of a fixed width ascii file using spacing 
records this is it.

If you had one file per planet and assuming that you wanted to start on 1900-01-01 

my $record_width=90;
my $offset = (($year-1900)*372+(($month-1)*31)+($day-1))*$record_width; 
# 1900-01-01 would be offset 0
# 2003-06-13 would be offset 3463560

This format would require blank records inserted for 1900-02-30 etc. but a simple 
script could auto generate the file.

One advantage of this would be the OS would file cache the read only file.

Just my toughts, hope it helps.

Paddy 

Reply via email to