you get my award for most 'novice' friendly thus far...much thanks
You’re quite welcome! Please keep in mine – a lot of the folks here are happy to help, and we’re just trying to guide you to finding your own solutions. As volunteers, we give it the time we have, and if there’s frustration, it’s often not due to meanness, just a wish for people to meet us half-way with questions.
Asking for broad-ranged aid on a situation is likely to led people to believe you wish tutoring, not aid on a specific topic; you can read the excellent Understanding and Using PerlMonks for more on how to ask questions 'round here. Does that put some of the reactions into perspective?
does php allow you the same flexibility as perl? i see courses in the adult ed for php, but nothing on perl
You do like the tough questions, don't you? :)
PHP is a distant relation to Perl, focused on publishing web pages. I confess to not having made anything with if, just editing and fiddling with a couple of pre-made apps, like Wordpress, that use PHP.
At a jump, and not to start another PHP vs. Perl flamewar, I'm going to say my impression is that PHP is very popular, in part because it’s easier to write websites in PHP as opposed to standard Perl -- although modules like Embperl offer very similar functionality -- and about the same level of basic connect-to-database extensions/modules as Perl. PHP seems to lack depth in the quantity and quality of Modules, as well as being somewhat more difficult to build extensive and complex web applications in.
I understand that PHP has something similar to Perl's taint mode, as well as the SQL-injection-resistant placeholder ability of DBI; their maturity, in comparison to Perl's years of experience (tainting has been a part of Perl since before the World Wide Web was created, much less CGI), is unknown to me. These aspects are, to me, critical in any Internet-facing web application.
To sum up: PHP is worth a try, and is currently far more popular than Perl -- yet it’s not nearly as flexible as Perl. Yet taking a good course on PHP beats out not learning anything by a country mile. :)
----Asim, known to some as Woodrow.
| [reply] |
Hi Asim,
OK, I'm back, a little beaten up, but much wiser. I have built a calendar widget from scratch using the Calendar::Simple pm. The prg is tested and works predictably (correctly as far as I can tell). When the program is invoked, a calendar for the current month is displayed. The user is allowed to pick a day, or select the previous or next month as desired. When the user selects a day, the program returns the yyyy-mm-dd as a string.
I would like some advice on how to bridge the final gap. How do I get this calendar widget to work within a CGI form?
# Calendar widget program. Creates pop-up calendar to select a date.
package CalendarWidget;
use strict; #force all variables to be declared before use
use CGI qw(:standard escape escapeHTML); # most common CGI interface f
+unctions
use CGI::Carp qw(warningsToBrowser fatalsToBrowser); #all diags to bro
+wser
use Calendar::Simple;
my $requested_new_month = param("requested_new_month");
my $specific_date_was_selected = param("specific_date_was_selected");
my $yyyy = param("yyyy"); my $mm = param("mm"); my $dd = param("dd");
sub calendar_widget
{ ####### dispatching logic begins here
if (defined (param("specific_date_was_selected"))) #spec date was sele
+cted
{
if ($specific_date_was_selected eq "specific_date_was_selected")
{return($yyyy,$mm,$dd);} # return selected date to calling pr
+ogram
else {}
}
elsif (defined (param("requested_new_month"))) # if request not curren
+t mo & yr
{
if ($requested_new_month eq "previous_month") # requested previous
+_month
{ # adjust calendar backward in time
if ($mm eq "1") # if previously displayed month was January
{
$mm = 12; # change new displayed month to December
$yyyy = $yyyy-1; # and adjust year
}
else # for all other months
{$mm = $mm-1; } #change new displayed month to previous mon
+th
}
else # requested_new_month was next_month
{ # adjust calendar forward in time
if ($mm eq "12") # if previously displayed month was December
{
$mm = 1; # change new displayed month to January
$yyyy = $yyyy+1; # and adjust year
}
else
{ $mm = $mm+1; } #change new displayed month to next month
}
show_calendar($mm, $yyyy); #show the revised calendar
}
else
{ show_calendar(); } #show calendar using current month / year
} ####### dispatching logic ends here
sub show_calendar
{
my ($specified_month, $specified_year) = @_; #get passed parms from ca
+lling pgm
my (@month, @row, @calendar_table_entry, @array, $array, $url1, $url2,
+ $theTime);
my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
my @weekDays = qw (Sun Mon Tue Wed Thu Fri Sat);
my ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfW
+eek, $dayOfYear, $daylightSavings, $year) = localtime();
$year = 1900 + $yearOffset;
$theTime = "$weekDays[$dayOfWeek], $months[$month] $dayOfMonth, $year
+$hour:$minute:$second";
my @month_names = qw(January February March April May June July August
+ September October November December);
if (($specified_month eq '') || ($specified_year eq '')) #if no date s
+pec'ed
{
@month = calendar($month+1, $year); # uses ACTUAL # of month & yea
+r
$specified_month = $month+1;
$specified_year=$year;
}
else # (month / year info were spec'ed, get info for specified month /
+ year
{
@month = calendar($specified_month, $specified_year);
}
$url1 = url().sprintf("?requested_new_month=%s&yyyy=%s&mm=%s",escape("
+previous_month"),escape($specified_year),escape($specified_month));
$url2 = url().sprintf("?requested_new_month=%s&yyyy=%s&mm=%s",escape("
+next_month"),escape($specified_year),escape($specified_month));
push (@row,qq(<table border=3 bordercolor="red" align="left" bgcolor="
+x00ffff">) );
my $i=0; my $j=0; @array = @weekDays; $array = param('@array');
push (@row, Tr (
( qq(<TD ALIGN="CENTER" VALIGN="CENTER", COLSPAN="7">), qq(<FONT CO
+LOR=#FF0000>), "$theTime", qq(</FONT>) ) ) );
push (@row, Tr (
( qq(<TD ALIGN="LEFT" VALIGN="CENTER", COLSPAN="1">), qq(<FONT COLO
+R=#0000FF>), (a({-href=>$url1},"<<")), qq(</FONT>) ),
( qq(<TD ALIGN="CENTER" VALIGN="CENTER", COLSPAN="5">), qq(<FONT CO
+LOR=#0000FF>), "@month_names[$specified_month-1] $specified_year", qq
+(</FONT>) ),
( qq(<TD ALIGN="RIGHT" VALIGN="CENTER", COLSPAN="1">), qq(<FONT COL
+OR=#0000FF>), (a({-href=>$url2},">>")), qq(</FONT>) )
) );
foreach $array(@array) # specify calendar days of week
{
@calendar_table_entry[$j] = $array;
$i++; $j++;
}
$j=0;
push (@row, Tr (
( qq(<TD ALIGN="RIGHT" VALIGN="CENTER", COLSPAN="1">), @calendar_ta
+ble_entry[$j] ), td (@calendar_table_entry[$j+1]), td (@calendar_tabl
+e_entry[$j+2]), td (@calendar_table_entry[$j+3]), td (@calendar_table
+_entry[$j+4]), td (@calendar_table_entry[$j+5]), td (@calendar_table_
+entry[$j+6])
) );
foreach (@month)
{
$j=0;
@array = @$_;
foreach $array(@array) # specify calendar numbered days in month
{
@calendar_table_entry[$j] = $array;
$i++; $j++;
}
$j=0;
push (@row, Tr (
( qq(<TD ALIGN="CENTER" VALIGN="CENTER">), qq(<FONT COLOR=#FF0000>)
+, (a({-href=>url().sprintf("?specific_date_was_selected=%s&yyy
+y=%04d&mm=%02d&dd=%02d", escape("specific_date_was_selected"), escape
+($specified_year), escape($specified_month), escape(@calendar_table_e
+ntry[$j]))}, @calendar_table_entry[$j])), qq(</FONT>) ),
( qq(<TD ALIGN="CENTER" VALIGN="CENTER">), (a({-href=>url().sprintf
+("?specific_date_was_selected=%s&yyyy=%04d&mm=%02d&dd=%02d",
escape("specific_date_was_selected"), escape($specified_year), escape(
+$specified_month),escape(@calendar_table_entry[$j+1]))}, @calendar_ta
+ble_entry[$j+1]))),
( qq(<TD ALIGN="CENTER" VALIGN="CENTER">), (a({-href=>url().sprintf
+("?specific_date_was_selected=%s&yyyy=%04d&mm=%02d&dd=%02d",
escape("specific_date_was_selected"), escape($specified_year), escape(
+$specified_month), escape(@calendar_table_entry[$j+2]))}, @calendar_t
+able_entry[$j+2]))),
( qq(<TD ALIGN="CENTER" VALIGN="CENTER">), (a({-href=>url().sprintf
+("?specific_date_was_selected=%s&yyyy=%04d&mm=%02d&dd=%02d",
escape("specific_date_was_selected"), escape($specified_year), escape(
+$specified_month), escape(@calendar_table_entry[$j+3]))}, @calendar_t
+able_entry[$j+3]))),
( qq(<TD ALIGN="CENTER" VALIGN="CENTER">), (a({-href=>url().sprintf
+("?specific_date_was_selected=%s&yyyy=%04d&mm=%02d&dd=%02d",
escape("specific_date_was_selected"), escape($specified_year), escape(
+$specified_month), escape(@calendar_table_entry[$j+4]))}, @calendar_t
+able_entry[$j+4]))),
( qq(<TD ALIGN="CENTER" VALIGN="CENTER">), (a({-href=>url().sprintf
+("?specific_date_was_selected=%s&yyyy=%04d&mm=%02d&dd=%02d",
escape("specific_date_was_selected"), escape($specified_year), escape(
+$specified_month), escape(@calendar_table_entry[$j+5]))}, @calendar_t
+able_entry[$j+5]))),
( qq(<TD ALIGN="CENTER" VALIGN="CENTER">), qq(<FONT COLOR=#FF0000>)
+, (a({-href=>url().sprintf("?specific_date_was_selected=%s&yyyy=%04d&
+mm=%02d&dd=%02d",
escape("specific_date_was_selected"), escape($specified_year), escape(
+$specified_month), escape(@calendar_table_entry[$j+6]))}, @calendar_t
+able_entry[$j+6])),
qq(</FONT>) )
) );
}
print table (@row);
return();
}
1;
| [reply] [d/l] |