Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

(jeffa) Re: Calendar

by jeffa (Bishop)
on Jul 24, 2002 at 14:39 UTC ( #184863=note: print w/replies, xml ) Need Help??


in reply to Calendar won't display day numbers

giulienk and giant are correct - use a CPAN module for this. But, i am sure that you are still itching to get this code work - the first glarring error i see (besides no strict!!) is this:
@thismonth = qw( $jandays $febdays $mardays $aprdays ... # you obviously meant: @thismonth = ($jandays,$febdays,$mardays,$aprdays, ...
But even with that fix, you will still get erroneous results. My advice? Start over, use strict, use the HTML methods from CGI - at least use CGI.pm's header(). Learn a templating module such as Template-Toolkit or (my favorite) HTML::Template. That or use one of the aforementioned CPAN modules that generats calenders (which is what i would really do).

Oh, by the way, hashes are great for storing the number of days in a given month:

my %days_in_month = ( jan => 31, feb => 28, # maybe? mar => 31, apr => 30, may => 31, etc ... );
But you have to account for leap years too ...

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---


(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re: (jeffa) Re: Calendar
by FoncÚ (Scribe) on Jul 24, 2002 at 15:24 UTC
    Man, would I love to utilize those modules, to simplify my life...but...I don't have access to install modules on our webserver (@#$% bad hosting!) and it costs $20 for them to install a module. A module, as in, singular. So...for the time being, I have to write this without the help of those modules.

    I'm not too worried about leap years, as this is not going to be a permanant script. It's a fix until the boss forks out some cash.

    I'll keep working with this...hopefully it will work well enough.


    FoncÚ
      Well, when you're in Rome, the Romans don't need to know everything you do. :)

      FTP the module to your cgi-bin directory. (Make sure you follow the directory paths for the leading bits of the module name though.)

      So for HTML::CalendarMonthSimple, you'd make the directory /path/to/your/cgi-bin/HTML and FTP the file CalendarMonthSimple.pm to that directory. Then put this line in your code:

      use lib '/path/to/your/cgi-bin';

      That will tell your script to look for modules in this directory first. (Technically, it prepends the @INC array with this path.)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://184863]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2023-06-07 22:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you go to conferences?






    Results (29 votes). Check out past polls.

    Notices?