Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: map, grep, for, foreach

by mt2k (Hermit)
on Jun 06, 2002 at 05:00 UTC ( #172079=note: print w/replies, xml ) Need Help??


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 ;))

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://172079]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2022-10-06 10:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (26 votes). Check out past polls.

    Notices?