Okay, I redid your script, and I think I got your intentions right. Let me know if I got it wrong.

#!/usr/bin/perl -w use strict; use CGI qw(:standard); my ($block_ref, $event_ref) = get_block(); print header(), start_html("Block Order Script"), h1("The Next Block Order is: "); my ($hour, $min, $day, $dotw) = (localtime)[2, 1, 7, 6]; my $time = sprintf "%02d%02d", $hour, $min; # Comments explained: (U M T W R F S) maps to (Sun Mon ... Sat) # If it's MTWR, and past 2:11pm, display tomorrow. if ((grep {$dotw == $_} (1, 2, 3, 4)) && $time > 1411) { $day++ } # If it's SU, display M. elsif (grep {$dotw == $_} (6, 0)) { my $adj = $dotw / 6 + 1; $day += $adj; } # If it's F, and past 2:11pm, display M. elsif ($dotw == 5 && $time > 1411) { $day += 3 } print p($block_ref->[$day]); print p($event_ref->[$day]); print end_html; sub get_block { my (@blocks, @events); open (BLOCK, "block.db") or die "$!"; while (my $date = <BLOCK>) { chomp ($date); chomp ($blocks[$date] = <BLOCK>); chomp ($events[$date] = <BLOCK>); } close (BLOCK); return (\@blocks, \@events); }

Note: This is very poorly tested -- Try using it on different times first -- I've only checked it for today.

His Royal Cheeziness


In reply to Re: Hash and Array Printouts in CGI by CheeseLord
in thread Hash and Array Printouts in CGI by wiz

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.