in reply to Re: I am a beginner in perl,not able to get the output for the following
in thread I am a beginner in perl,not able to get the output for the following

This node falls below the community's minimum standard of quality and will not be displayed.
  • Comment on Re^2: I am a beginner in perl,not able to get the output for the following

Replies are listed 'Best First'.
Re^3: I am a beginner in perl,not able to get the output for the following
by SFLEX (Chaplain) on Sep 04, 2007 at 12:09 UTC
    Its kinda big, but its works..
    #!/usr/bin/perl use CGI; my %months = ( 0 => 'January', 1 => 'February', 10 => 'November', 11 => 'December', 2 => 'March', 3 => 'April', 4 => 'May', 5 => 'June', 6 => 'July', 7 => 'August', 8 => 'September', 9 => 'October', ); my $date = CGI::Util::expire_calc('',''); # get time my $time_offset = 0; # offset time in hours (-12 to 12) my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime($date + 3600 * $time_offset); my ($formatted_date, $cmon, $cday, $syear); $year += 1900; $cmon = $mon + 1; if ($hour < 10) { $hour = 0 . $hour; } if ($min < 10) { $min = 0 . $min; } if ($sec < 10) { $sec = 0 . $sec; } $cday = ($mday < 10)? 0 . $mday : $mday; my $ampm = 'am'; if ($hour > 11) { $ampm = 'pm'; } if ($hour > 12) { $hour = $hour - 12; } if ($hour == 0) { $hour = 12; } if ($mday > 10 && $mday < 20) { $cday = '<sup>th</sup> +'; } elsif ($mday % 10 == 1) { $cday = '<sup>st</sup>'; } elsif ($mday % 10 == 2) { $cday = '<sup>nd</sup>'; } elsif ($mday % 10 == 3) { $cday = '<sup>rd</sup>'; } else { $cday = '<sup>th</sup>'; } $formatted_date = "$hour:$min$ampm, $mday$cday, $month +s{$mon}, $year "; print "Content-type: text/html\n\n"; print "<html><h1>$formatted_date</h1></html>\n";