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

#!/usr/bin/perl -w use strict; use CGI qw(:standard); use Date::Calc qw(:all); use CGI::Carp qw(fatalsToBrowser warningsToBrowser); use HTML::AsSubs; use HTML::Element; use HTML::CalendarMonth; my $data="/path/data.txt"; my @Calendar = (); #my $checkthree = "1000"; my $checkthree = param ('check'); open (FILE,"$data") || die "whoops 1: $!"; my @all=<FILE>; close (FILE); foreach my $line (@all){ my ($one,$two,$three,$four,$five,$six,$seven,$eight) = split "\t", +$line; if ($three eq $checkthree) { @Calendar = split /\s+/,$seven; } } my @dates = sort @Calendar; print header(), start_html(-title => "Calendars"); while (defined $dates[0]) { my $days = $dates[0]; my ($year, $month, $day) = Add_Delta_Days(1,1,1, $days - 1); @dates = CreateCal($year, $month, @dates); } print end_html(); exit(0); sub CreateCal { my ($cyear, $cmonth, @dates) = @_; my (@days, @temp); foreach my $days (@dates) { my ($year, $month, $day) = Add_Delta_Days(1,1,1, $days - 1); if ($year == $cyear && $month == $cmonth) { push (@days, $day); } else { push (@temp, $days); } } my $c = new HTML::CalendarMonth( month => $cmonth, year => $cyear, ); $c->item($c->month)->wrap_content(font({size => '+2'})); $c->item($c->dayheaders)->wrap_content(font({size => '-1'})); $c->item(@days)->attr(bgcolor => '#CC0000'); print "<p>", $c->as_HTML, "</p>"; return @temp; }
(appreciation to Mr. Muskrat for the main part of the script)

My problem is that when I take a value via param( ) the result is a blank screen. If I comment out the param( ) line and use uncommentedmy $checkthree = "1000"; the script works fine.

Careful debugging led me to the use HTML::AsSubs; but I'm afraid I'm not knowledgable enough to get to the bottom of it.

I wonder if anyone could help me?

Replies are listed 'Best First'.
Re: Problem with param( ) in Calendar script
by Mr. Muskrat (Canon) on Nov 26, 2002 at 21:51 UTC

    Hello again, jonnyfolk.

    You have a conflict between CGI and HTML::AsSubs. Both modules have a param() method.

    If you create a CGI object and use the param() method on it, it will work.

    my $cgi = new CGI(); my $data="/path/data.txt"; my @Calendar = (); #my $checkthree = "1000"; my $checkthree = $cgi->param('check');

      Thanks once again, Mr. Muskrat

      I haven't dealt with objects yet - that's a great solution to this problem so I shall do some reading and get them in my armoury!