dpath2o has asked for the wisdom of the Perl Monks concerning the following question:

Hi!
I'm trying to find the most efficient way of solving a seemingly simple problem, but I'm finding exceedingly complex.
So what I need to do
1.) build a list file links that are files that I'm recommending to users of my data
2.)plot a timeline of recommended files

The files are found in two base directories: /Volumes/Archives0 & /Volumes/Archives1 . Archives0 path contains data < 2008. Files are then stored in each base directory have the following path: $basedirectory.'/Data/SITE/TYPE/YYYY_MO/'. The file format is as such TYPE_SITE_YYYY_MO_MD_HH00.ruv , where
TYPE = RDL[i|m]
SITE = a list of four character strings
YYYY = four digit year
MO = two digit year
MD = two digit month day
HH = two digit hour

OK, so that's the structure that I'm dealing with. Now I have created arrays that depict when to use RDLi or RDLm -- i.e. when to change from RDLi to RDLm or vice versa (see code below, @changeTimes, @changeNames, @changeTypes).
I'd like to create links to radial files /Volumes/ArchivesΎ|1] that change with the @changeTimes, which corresponds to @changeNames and ultimately corresponds @changeTypes. I would like to create links for these files in /Volumes/Extras/RecommendedRadials/SITE/YYYY_MO
Any advice that you might have to do this in PERL would be great. Unfortunately I can't seem to get "sudo perl -MCPAN -e "install DBD::mysql"" to work so I can't use mysql which my might be good to keep all these files in instead of this /Volumes/Archives ... format.
Regardless, I need to get this done and have spun my wheels on this and am not feeling like I've got a good handle on it.
In regards to plotting a timeline of the recommended files -- i.e. a plot that show a tic mark for each file. Lets say if the above code was called radials.pl then calling it from the command line as "radials.pl --timeline <SITE> <START> <STOP>" would print a gnuplot of the available radials from that time. Maybe even another option to tar and zip the found files.
Ultimately I'd like to put all of this into a CGI that someone can navigate and perform these tasks interactively.

THANK YOU! Her's what I've written so far:
#!/usr/local/ActivePerl-5.10/bin/perl # #all things radials # # GPL, copyright 2008 use strict; use Getopt::Long; use Date::Calc qw(:all); #build the variables my $startdate = Mktime(2006,1,1,0,0,0); my %archiveDirs = ( "2007","/Volumes/Archives0", "2008","/Volumes/Archives1" ); my @mntySites = qw( pesc bigc scrz mlml mlng npgs ppin gcyn psur psl +r ); my @mntyTypes = qw( i i m i m m m i m +i ); my $recommedDir = qw( /Volumes/Extras/RecommendedRadials ); my @commaTimes = qw( 2006,02,03,19,00,00 2006,03,03,09,00,00 2006,04,14,22,00,00 2006,07,07,22,00,00 2006,07,20,19,00,00 2006,08,10,20,00,00 2006,10,17,21,00,00 2006,11,06,23,00,00 2006,11,27,20,00,00 2006,12,18,21,00,00 2007,03,19,20,00,00 2007,05,09,20,00,00 2007,08,04,19,00,00 2007,08,06,16,00,00 2007,09,09,08,00,00 ); my @changeTimes; foreach my $l1 (@commaTimes) { my @tmp = split(/\,/,$l1); my $tmpT = M +ktime(@tmp); push(@changeTimes,$tmpT); } my @changeNames = qw( SCRZ PPIN NPGS PPIN NPGS MLNG MLNG NPGS NPGS MLML SCRZ PSUR RAGG PSUR PSUR ); my @changeTypes = qw( i i i m m i m i m m m i m m i ); my $cnt=0; print "%Table of radials going from measured to ideal or vice versa\n" +; print "%Table used to build recommended radial links in $recommedDir\n +"; print "%Table start date (epoch seconds): $startdate\n"; print "%Prior to $startdate then the recommend radial table is as foll +ows\n"; foreach my $l1 (@mntySites) { print "%\t$l1\tmeasured\n" if ($mntyTypes[$cnt] =~ m/m/) ; print "%\t$l1\tideal\n" if ($mntyTypes[$cnt] =~ m/i/) ; $cnt++; } $cnt=0; print "%NOTE: radial site may or may not exist prior to $startdate\n"; print "%\tTry using radial.pl --timeline <SITE> <START> <STOP>\n%%%\n" +; print "%TABLE:\tEpoch Time\tSite\tType\n"; foreach my $l1 (@changeTimes) { print "\t$l1\t$changeNames[$cnt]\tmeasured\n" if ($changeTypes[$cn +t] =~ m/m/); print "\t$l1\t$changeNames[$cnt]\tideal\n" if ($changeTypes[$cnt] +=~ m/i/); $cnt++; }

Replies are listed 'Best First'.
Re: Create Links dependent upon conditions and plotting a timeline
by wjw (Priest) on May 13, 2009 at 00:47 UTC
    I know this is way late in the game and probably won't even be read, but then who knows? I was reading back this far..

    There is a cute little open source project called SIMILE Timeline (along with some others). I have been implementing it at work to show events(and each events details when mouse clicked) on a mfg line. I have been very impressed with it. It has a small but active user group on google groups.

    Be warned, et is poorly documented at best. However, with a bit of playing around with the examples, it does not take too long to have a very nice timeline. I use perl on the back end to talk to a database and spit out XML to populate the timeline with events. Very fast, very simple. I will quit plugging it and just give the url.

    SIMILE

    • ...the majority is always wrong, and always the last to know about it...
    • The Spice must flow...
    • ..by my will, and by will alone.. I set my mind in motion