http://qs321.pair.com?node_id=172079


in reply to map, grep, for, foreach

Okay I screwed that example up... Last line should say:

while (my($n,$v) = each %input) { print "$n: $v<br>"; }

It won't work the way I have it for 2 reasons: 1. I kinda threw a semi-colon in between the EXPR and the loop 2. You must show the loop first when initializing variables within the loop statement (in order to satisfy strict).

And okay, so the following code would work:

#!c:/perl/bin/perl -w use strict; use CGI 'Vars'; my %input = CGI::Vars; print "Content-type: text/html\n\n"; while (my($n,$v) = each %input) { print "$n: $v<br>"; }

Let's go to lala land and pretend CGI.pm could not do this. What would be the best alternative? (By the way, thanks. I have already modified my scripts to use this wonderful CGI::Vars ;))