I don't think you need that hash %normal_hrs as you have all the info in the returned SQL query. So, I think this version will be simpler without the hash initialization. Also, I made a minor change to the way the dates, (day_of_week and names), were created.
# -- connect to Voyager db my $dbh = DBI->connect( $voy_dsn,$voy_dbun,$voy_dbpass, { AutoCommit = +> 0, RaiseError => 0, PrintError => 1 } ) || die $DBI::errstr; # -- get normal hours of operations # -- yes, believe it or not there is only one row (there must be a rea +son for this setup but I can't think of one) my $sql = qq(SELECT sunday_open,sunday_openhour,sunday_closehour, monday_open,monday_openhour,monday_closehour, tuesday_open,tuesday_openhour,tuesday_closehour, wednesday_open,wednesday_openhour,wednesday_closehour, thursday_open,thursday_openhour,thursday_closehour, friday_open,friday_openhour,friday_closehour, saturday_open,saturday_openhour,saturday_closehour FROM calendar WHERE calendar_desc = '$voy_cal2use'); my $sth = $dbh->prepare( $sql ); $sth->execute; my @row = $sth->fetchrow->array; my $today = today; my @day = map $today + $_, 0 .. 6; my @data; for my $i (0 .. 6) { push @data, {dow => $day[$i]->day_of_week, name => $day[$i]->strftime("%A")}; } my $date = shift @data; # you have $date->{name} here too my $i = 3 * $date->{dow}; my @today_info = @row[$i .. $i+2]; # write today's info to html # drop down list for my $date (@data) { # You have access here to $date->{dow} and $date->{name} my $i = 3 * $date->{dow}; my @info = @row[$i .. $i+2]; # write this day's info to drop down list }

In reply to Re^2: Sorting Days of Week Using today () to today () + 6 by Cristoforo
in thread Sorting Days of Week Using today () to today () + 6 by Hans Castorp

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.