Try this code:

use Time::Local;
$date = time();
for ($i=0;$i<6;$i++){
   my $thisMonth = uc(substr(localtime($date - $i*(31 * 24 * 60 *
60)),4,3));
   print "<OPTION VALUE=\"$thisMonth\">$thisMonth\n";
}


Will this help you?

Josimar


----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, October 30, 2002 7:33 AM
Subject: Comparing array elements with scalar variables.


> I've have some code that prints a column of a database table into a html
> form.  The column of the table is just the last 6 months of the year:
>
> my @emonth;
> while ( @emonth = $end_Months->fetchrow_array()) {
>   print HTML "<OPTION VALUE=\"@emonth\">@emonth\n";
> }
>
> returns:
> <OPTION VALUE="MAY">MAY
> <OPTION VALUE="JUN">JUN
> <OPTION VALUE="JUL">JUL
> <OPTION VALUE="AUG">AUG
> <OPTION VALUE="SEP">SEP
> <OPTION VALUE="OCT">OCT
>
> i've got the current month stored in a scalar variable:
> my $thisMonth = (split ' ', uc localtime)[1];    #equates to 'OCT'
>
> i want to print <OPTION SELECTED= if the month is equal to the current
> month...ie.
> <OPTION VALUE="MAY">MAY
> <OPTION VALUE="JUN">JUN
> <OPTION VALUE="JUL">JUL
> <OPTION VALUE="AUG">AUG
> <OPTION VALUE="SEP">SEP
> <OPTION SELECTED="OCT">OCT
>
> i've tried many ways of doing this and it seems that perl can't compare
> scalar variable with array elements, does anyone know of a way of doing
> this??
> any help would be much appreciated, cheers!
>
> Jonathan Musto
>
>
>
> BT Ignite Solutions
> Telephone - 0113 237 3277
> Fax - 0113 244 1413
> E-mail -  <mailto:Jonathan.Musto@;bt.com> [EMAIL PROTECTED]
> http://www.technet.bt.com/sit/public
<http://www.technet.bt.com/sit/public>
>
>
> British Telecommunications plc
> Registered office: 81 Newgate Street London EC1A 7AJ
> Registered in England no. 1800000
> This electronic message contains information from British
Telecommunications
> plc which may be privileged or  confidential. The information is intended
to
> be for the use of the individual(s) or entity named above. If you  are not
> the intended recipient be aware that any disclosure, copying, distribution
> or use of the contents of  this information is prohibited. If you have
> received this electronic message in error, please notify us by  telephone
or
> email (to the numbers or address above) immediately.
>
>
>
>
>
>



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to