[ic] Looping through form variables in [perl] tag

Peter peter at pajamian.dhs.org
Wed Apr 9 03:22:16 UTC 2008

On 04/08/2008 07:10 PM, tom at readyink.com wrote:
> I should be able to do
> [tmp][perl]
> while (($key, $value) = each %CGI::values) { }
> ## or
> foreach my $key ( keys %CGI::values ) {}
> [/perl][/tmp]
> because I see code like that in the core, but it doesn't work.  Can
> someone tell me how to loop through the form variables?

The code that you can use in [perl] and [calc] blocks is different from 
what is used in the core.  This is because [perl] blocks are subject to 
safe hole restrictions.  In your code above you would use %$CGI instead 
of %CGI::values:

while (my ($key, $value) = each %$CGI) {

For a list of perl variables you can use in [perl] and [calc] blocks and 
their equivalents in the core see:


More information about the interchange-users mailing list