For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > March 2004 > Week Numbers lists









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Week Numbers lists
Mike Blezien

2004-03-31, 5:33 pm

Hello,

I need to create a dropdown list of w numbers ranging from the current w
number to w number 01. The w number would be obtain from a MySQL database,
IE: select w(curdate()); this equals 13

and from this w#, then I need to generate a list from that w number, IE.
12,11,10,09,07,...etc., down to 01

What would be the best way in perl to do this ??

TIA
--
Mike<mickalo>Blezien
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Thunder Rain Internet Publishing
Providing Internet Solutions that work!
http://www.thunder-rain.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Paul Johnson

2004-03-31, 5:34 pm

On Wed, Mar 31, 2004 at 03:23:49PM -0600, Mike Blezien wrote:

> Hello,
>
> I need to create a dropdown list of w numbers ranging from the current
> w number to w number 01. The w number would be obtain from a MySQL
> database, IE: select w(curdate()); this equals 13
>
> and from this w#, then I need to generate a list from that w number,
> IE. 12,11,10,09,07,...etc., down to 01
>
> What would be the best way in perl to do this ??


How about something like:

@l = map sprintf("02d", $_), reverse 1 .. $curdate - 1;

Make sure you understand everything that is going on there.

--
Paul Johnson - paul@pjcj.net
http://www.pjcj.net
Paul Johnson

2004-03-31, 5:34 pm

On Wed, Mar 31, 2004 at 11:38:56PM +0200, Paul Johnson wrote:
> On Wed, Mar 31, 2004 at 03:23:49PM -0600, Mike Blezien wrote:
>
>
> How about something like:
>
> @l = map sprintf("02d", $_), reverse 1 .. $curdate - 1;


Ha! Now I'm doing it too ;-)

@l = map sprintf("%02d", $_), reverse 1 .. $curdate - 1;

( Note the addition of a % )

--
Paul Johnson - paul@pjcj.net
http://www.pjcj.net
Mike Blezien

2004-03-31, 5:34 pm

Thx's Paul,.. I caught the %0.2d change right away... thought it looked alittle
weired :)

alot more elegant that what I original had in place,..works great! ;)

Appreciate the help.

--
Mike<mickalo>Blezien
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Thunder Rain Internet Publishing
Providing Internet Solutions that work!
http://www.thunder-rain.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Paul Johnson wrote:
> On Wed, Mar 31, 2004 at 11:38:56PM +0200, Paul Johnson wrote:
>
>
>
> Ha! Now I'm doing it too ;-)
>
> @l = map sprintf("%02d", $_), reverse 1 .. $curdate - 1;
>
> ( Note the addition of a % )
>




Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com