Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
Perl: loop through namespace
Old 10-10-2008, 12:56 PM Perl: loop through namespace
Experienced Talker

Posts: 33
Trades: 0
Greetings,

I am trying to figure out how to loop through a namespace.
For example:

URL: http://path/to/test.pl?name=nick&hair=brown


Contains:
Code:
#!/usr/bin/perl
use CGI;

$query = new CGI;
$query->import_names("FORM");

print "Content-type: text/plain\n\n";

while(($key,$value)=each(%FORM::)){
        print "$key\n";
        print "$value\n";
}
Returns:
name
*FORM::name
hair
*FORM::hair


What I was really hoping for was:
name
nick
hair
brown


I would prefer to utilize the namespace (FORM) since it's already establish in the script and part of the bigger picture.
Hopefully you can provide me with some advice on how to proceed.

Thanks,
nick1 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-10-2008, 02:49 PM Re: Perl: loop through namespace
Experienced Talker

Posts: 33
Trades: 0
Update:

I found my answer:

Code:
while(($key,$value)=each(%FORM::)){
       print "$key\n";
       print "${$value}\n";
}
nick1 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Perl: loop through namespace
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.17012 seconds with 12 queries