Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: A Beginner Apparently Sucks With Hashes...

by CheeseLord (Deacon)
on Jul 22, 2001 at 10:28 UTC ( #98778=note: print w/replies, xml ) Need Help??


in reply to A Beginner Apparently Sucks With Hashes...

I can tell you why it happens... this line right here:

%FormData = split(/=/, $Part);

Inside that foreach loop, you're overwriting the hash each time. You'll probably want to do something like this:

my ($name, $value) = split /=/, $Part; $FormData{$name} = $value;

However... there are MUCH easier ways to do parameter grabbing, and I (along with 99% of the monastery) suggest you check out and use CGI.pm, along with strict and -w, if you aren't already. Hope that helps!

Update: Added example code.

His Royal Cheeziness

Replies are listed 'Best First'.
Re: Re: A Beginner Apparently Sucks With Hashes...
by CharlesClarkson (Curate) on Jul 22, 2001 at 11:19 UTC

    Following CheeseLord's advice might lead to something like:

    #!/usr/bin/perl -w use strict; use diagnostics; use CGI qw/:standard Vars/; use CGI::Carp 'fatalsToBrowser'; my @page; my %form_data = Vars; foreach my $input_name (keys %form_data) { push @page, p( {-align => 'center'}, b($input_name), ": $form_data{$input_name}" ); } print header, html(@page);

    HTH,
    Charles K. Clarkson

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://98778]
help
Chatterbox?
[choroba]: The documentation just says the second argument should be "characters"
[Eily]: It can also be used to force a copy, and remove magic from a variable
[Eily]: there was a post some time ago about variable coming from regex taking more space than the same string defined directly IIRC

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2018-02-22 17:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (296 votes). Check out past polls.

    Notices?