[ic] Loop with embedded Perl

Mike Heins mike at perusion.com
Mon Aug 1 10:30:02 EDT 2005

Quoting Jeff Boes (jeff at endpoint.com):
> I'm stuck on this:
>         <select name="year">
>         <option value="">Select one</option>
>         [loop list=`1981..1900+(localtime())[5]`
>          ] <option value="[loop-code]">[loop-code]</option>
>         [/loop]
>         <option value="prior 1981">1980 or older</option>
>         </select>
> What I'm attempting to generate is a drop-down list with a series of
> year values, 1981 to the current year.
> If I can get this working, what I'd really like is ..
> list=`reverse 1981..1900+(localtime())[5]`
> but at present neither of these works; I get an empty list and only the
> last option.

You might want to join it with something. [loop ...] is ITL, not
Perl, and it doesn't accept Perl array values directly...

         [loop list=`
			my $year = 1900 + (localtime())[5];
			return join(" ", 1981 .. $year);
          ] <option value="[loop-code]">[loop-code]</option>

Sometimes trying to be too terse causes problems. I suggest that
when you have trouble you just write a function and skip the
mimimalist one-liner approach. And not using whitespace makes
code much harder to read.

Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.765.647.1295  tollfree 800-949-1889 <mike at perusion.com>

People who want to share their religious views with you
almost never want you to share yours with them. -- Dave Barry

More information about the interchange-users mailing list